###目的
次にように【投稿タイプ】とカスタムフィールドがあるのですが…
【通常の投稿タイプ】
→tag_postというカスタムフィールド名があり、値はAとBの2つがある。
【カスタム投稿タイプ】
→tag_customというカスタムフィールド名があり、値はAとBの2つがある。
…これらの【投稿タイプ】にかかわらず、同じ値を持つ記事の一覧ページを作りたいと思っています。
###試したこと
次のように
'post_type' => 'post', 'custom',
'meta_key' => 'tag_post', 'tag_custom',
としてみたのですが、postのtag_postしか拾ってくれません。(>_<)
どうにかしてcustomのtag_customも一緒に表示する方法はありませんでしょうか?
php
1<main id="main"> 2 <div class="list"> 3 4 <?php 5 $url = $_SERVER["REQUEST_URI"]; 6 $str = str_replace('/', '', $url); 7 $tag = urldecode($str); 8 ?> 9 10 <?php $args = Array( 11 'post_type' => 'post', 'custom', 12 'posts_per_page' => -1, 13 'meta_key' => 'tag_post', 'tag_custom', 14 'meta_value' => $tag 15 ); 16 $the_query = new WP_Query($args); 17 if($the_query -> have_posts()): 18 while($the_query -> have_posts()): $the_query -> the_post(); 19 20 get_template_part( 'template-parts/single', 'list' ); 21 22 endwhile; 23 endif; 24 wp_reset_postdata(); ?> 25 26 </div> 27 28 <?php pingraphy_the_posts_navigation(); ?> 29 30</main>
あなたの回答
tips
プレビュー