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!!

1 Answer 1


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 B. Example :

$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 ?>

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.