I have created two custom post type. Suppose A and B.
I would like to fetch A custom post title in B in meta box in a drop-down.
I am not getting any solution.
Is anybody help me to find the solution.
Thanks in advance!!
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
You need to get all the titles of CPT (
Custom Post Type)
A, and loop through them in the second CPT in a metabox of CPT
$my_titles = array( 'post_status' => 'publish', 'posts_per_page' => -1, 'order' => 'ASC', 'post_type' => 'my_custom_post_type' // get the type of your CPT );
Now in your second custom post type i.e
B, inside the
meta box loop through them like
<select name="" id=""> <?php foreach ($my_titles as $key => $title): ?> <option value=""><?php echo $title; ?></option> <?php endforeach ?> </select>