カスタムポストタイプコールがあります 'セクタ'と呼ばれ、別のポストタイプは 'チャレンジ'と呼ばれます。チャレンジポストタイプは 'セクトタイプ'というタクソノミーを持ちます。ワードプレスループ引数に変数を追加する
私は 'single-sector.php'というページを作成しました。そのページには、そのセクターに関連する課題を含むループが表示されます。
私はチャレンジを表示するためのループを書くときに、 'sectortype' => 'advanced-education'を変数にして他の単一セクタのページでも使用できるようにするにはどうすればよいですか?別のページ 、IN
<?php
$terms = get_terms('sectortype');
$challenge_args = array(
'post_type' => 'challenge',
'publish_status' => 'published',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'sectortype',
'field' => 'slug',
'terms' => $terms[0], //whichever term you want to select
),
),
);
// create a new instance of WP_Query
$challenge_query = new WP_Query($challenge_args);
?>
<?php if ($challenge_query->have_posts()) : while ($challenge_query->have_posts()) : $challenge_query->the_post(); // run the loop ?>
DISPLAYは、別のページで記事を表示するには:ここで
は<?php $challenge_args = array(
'post_type' => 'challenge',
'sectortype' => 'advanced-education', //Need Help Here
);
// create a new instance of WP_Query
$challenge_query = new WP_Query($challenge_args);
?>
<?php if ($challenge_query->have_posts()) : while ($challenge_query->have_posts()) : $challenge_query->the_post(); // run the loop ?>
タクソノミーについては、私はビジネス、高度な教育などのカテゴリを持っています。あなたが提供した編集では、各タクソノミの投稿を正しいページに表示する必要があります。 1? – user3331701
アップデートを参照し、問題が解決する場合はこれを「合格」とマークしてください。ハッピーコーディング!! – Bayou