0
我有一个名为customer_care的自定义帖子类型,它使用一个名为customer-care.php的模板。如何使用自定义帖子类型在父帖子类型中显示子帖子类型?
我创建了一个新的customer_care,叫做联系我们,并创建了一个叫做办公地址的孩子。
如何获取办公地址孩子的永久链接显示在联系我们(customer-care.php)上。
如何显示家长帖子和孩子帖子后和点击后显示内容。
我也使用数据ID & jquery。
我将不胜感激提供的任何帮助!
//for display parent post
<?php
\t $args = array('posts_per_page' => 10, 'offset'=> 0, 'orderby' => 'menu_order' , 'post_type' => 'customer_care');
\t \t \t \t \t \t
\t $myposts = get_posts($args);
\t \t
\t foreach ($myposts as $post) : setup_postdata($post);
?>
<li><a class="service-category-select" data-id="<?php echo strtolower($post->post_title);?>"><?php the_title() ?><span class="arrow"></span></a></li>
\t <?php
\t \t \t endforeach;
\t \t \t wp_reset_postdata();
?>
\t \t \t \t
//for display child post
<!-- START: LOOP -->
<?php
\t \t $args = array('posts_per_page' => 10, 'offset'=> 0, 'post_type' => 'customer_care');
\t \t \t \t \t \t
\t $myposts = get_posts($args);
\t \t
foreach ($myposts as $post) : setup_postdata($post);
?>
\t <nav class="sub-content ng-hide" data-id="<?php echo strtolower($post->post_title); ?>">
\t \t \t \t <header class="title"><a class="service-list"><span class="arrow"></span><?php echo $post->post_title ?></a></header>
\t \t \t \t <ul>
\t \t \t \t
\t \t \t \t \t <li>
\t \t \t \t \t \t <a class="service-detail-selector" data-id="customer-care">Customer care <span class="arrow"></span></a>
\t \t \t \t \t </li>
\t \t \t \t \t
\t \t \t \t </ul>
\t \t \t </nav>
\t \t \t \t <?php
\t \t \t \t \t \t endforeach; \t \t
\t \t \t \t \t \t wp_reset_postdata();
\t \t \t \t ?>
<?php //endif; ?>
<!-- END: LOOP -->
例:https://codex.wordpress.org/Function_Reference/get_children –
也试试这个..不工作 – bhautikmodi8
请分享您的代码 –