admin管理员组文章数量:1315325
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!!
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!!
Share Improve this question asked Nov 20, 2020 at 8:39 Neeraj PrasadNeeraj Prasad 13 bronze badges1 Answer
Reset to default 0You 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 ?>
</select>
本文标签: plugin developmentShow a custom post title in another custom post type in Meta box
版权声明:本文标题:plugin development - Show a custom post title in another custom post type in Meta box 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741976063a2408128.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论