私は、customer-care.phpというテンプレートを使用するcustomer_careというカスタム投稿タイプを持っています。カスタム投稿タイプを使用して親投稿タイプに子投稿タイプを表示するにはどうすればよいですか?
私は連絡先と呼ばれる新しいcustomer_careを作成し、このオフィスアドレスと呼ばれる子を作成しました。
どのように連絡先(customer-care.php)にオフィスアドレスの子供のパーマリンクを表示させるのですか?
親の投稿を表示する方法と、子供の投稿を表示した後にコンテンツを表示する方法をクリックする方法。
私もdata-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
あなたのコードを共有してください –