0

Simple you will say?

I have a first Custom post type called Country. I have a second Custom post type called Travellers. I need to make a drop down select list (multiple check) available when editing Countrywith content from Travellers. This will allow me to select travellers for each country.

Help!

thx in advance

1

3 Answers 3

1

very simeler to the question here Display list of tags as drop down menu or radio buttons in a meta box?

but instead of list of tags you need to query the post list of your travellers post type something like this:

$travelers = new WP_Query();
$travelers ->query('post_type=travelers&postprepage=-1');
while ($travelers->have_posts()) : 
   $recentPosts->the_post();
   $travellersnames[] = $post->title;
endwhile

and show the $travellersnames as your option for a select filed or multi select filed in your meta box

1
  • glad i can help
    – Bainternet
    Commented Jan 24, 2011 at 17:12
0

I am trying to accomplish this same thing, but the code here is not working for me... is the syntax all correct? I have a basic working knowledge of PHP, but I can't tell what's going on here.

Perhaps some clarification?

Thanks in advance!

4
  • My original question: wordpress.stackexchange.com/questions/7462/…
    – user2655
    Commented Jan 24, 2011 at 21:38
  • Hi ben, the code works by querying a custom taxonomy , in my example slide. May be paste your code and let see if we can help
    – salocin
    Commented Jan 25, 2011 at 8:09
  • Ben, please do not use an Answer to ask a question. Either start a new question, or post a comment (either to the OP here, or to one of the answers). Once you've done that please delete your answer here. Commented Jan 25, 2011 at 13:19
  • Sorry about that! I hesitated at first but this thread would not allow me to comment on previous answers for some reason. I see the last answer has been reformatted placing the code in the code box, so I'll mess with that and delete this answer...
    – user2655
    Commented Jan 25, 2011 at 17:37
0

Following the answer I ended up with

$s_query = new WP_Query( array(
    'suppress_filters' => false,
    'post_type' => 'slide'));
while($s_query->have_posts()):$s_query->the_post();

    $sname = $post->post_title;
    $s_output2 ='';
    $s_output2 .= '<option value="'.$post->ID.'" >';
    $s_output2 .= $post->post_title;
    $s_output2 .= '</option>';
    echo $s_output2;

endwhile ;
wp_reset_query();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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