Reputation: 551
I have the following custom post types set up in my wordpresss installation: Clients and Testimonials.
In Testimonials custom post types I have these fields (simplified):
In Clients custom post type I have these fields (simplified):
Question: Currently the "Client name" field in the "Testimonials post type is a text box but would like this to be a drop down list based on the entries in the "Clients" post type.
Ideally, I would like to do this without a plug-in if possible.
Thanks
Upvotes: 0
Views: 341
Reputation: 709
You can achieve this using get_posts in select box like as follows
<select>
<?php
$all_client = get_posts(array('post_type'=> 'Client-post-type','posts_per_page' => -1) );
foreach($all_client as $single_client){
echo "<option value='".$single_client->ID."'>'".$single_client->post_title."'</option>";
}?>
</select>
Upvotes: 1