WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to add CPT values in a drop-down menu within another CPT, not sure if this is do-able. Basically I have a Store CPT and a Manager CPT, in the manager cpt i have regular posts with the title, featured image, etc and what I would like to do is when I add a new store (on the Store CPT) i'd like to have a drop-down menu filled with the titles of Managers to be selected and associated, so that on the store page I can display the store manager as well.

A point in the right direction would be appriciated.

*CPT = Custom Post Type

share|improve this question

Three suggestions:

1. Create Your Own Metabox

This is your original idea: when creating/editing the Store post type, the metabox will display a dropdown with all the available Managers of this post type.

For that, use Bainternet's answer to this Question as a starting point, and change the get_categories for a get_posts of your CPT.
This will be stored as post meta and retrieved normally with a get_post_meta.

2. Use Post 2 Posts Plugin

I never really used this one, but I know it's done for this kind of scenario and its author is a WordPress heavy weight...

In both plugin cases, read the documentation for the retrieval method.

3. Use Advanced Custom Fields Plugin

Another actively maintained plugin with plenty of custom fields goodies.

The field types Relationship or Post Object can be used for this purpose.

Bellow the screenshots of a test configuration using the post types Movies and Actors with a Relationship field (more complex than Post Object, which would produce a simple dropdown).

Field Configuration
click to enlarge field configuration

Field Result
click to enlarge field result

share|improve this answer
Wow thanks for your reply, this very helpful. – Beto Nov 18 '12 at 7:13

You can use the Posts 2 Posts plug-in, or you can do it yourself with something like the following (untested):

add_action( 'add_meta_boxes', 'wpa71126_add_meta_box' );
add_action( 'save_post', 'wp71126_save_post' );

function wpa71126_add_meta_box() {
        __( 'Managers', 'textdomain' ),

function wpa71126_meta_box( $post ) {
    $args = array(
        'post_type' => 'manager',
        'name'      => 'wpa71126_manager_dropdown'

    wp_nonce_field( plugin_basename( __FILE__ ), 'wp71126_nonce' );

    echo '<label>';
    _e('Select a manager', 'textdomain' );
    wp_dropdown_pages( $args );
    echo '</label> ';

function wp71126_save_post( $post_id ) {
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 

    if ( ! wp_verify_nonce( $_POST[ 'wp71126_nonce' ], plugin_basename( __FILE__ ) ) )

    // Check permissions
    if ( 'manger' == $_POST[ 'post_type' ] )  {
        if ( !current_user_can( 'edit_post', $post_id ) )

    $manager = $_POST[ 'wpa71126_manager_dropdown' ];

    update_post_meta( $post_id, '_manager', $manager );
share|improve this answer
How would I show that in the front end though? – Beto Nov 15 '12 at 19:46
You can still use wp_dropdown_pages() on the front end, but I am not sure how because I do not have your code in front of me. Please update your question with the code that you are using to do the front end editing. – Joseph Leedy Nov 15 '12 at 20:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.