functions.phpに関数を書く
function myquery_args() {
global $myquery_args;
$myquery_args = array(
'post_type' => '投稿タイプ',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'タクソノミー名',
'field' => 'slug',
'terms' => 'ターム名',
),
),
);
}
add_action( 'after_setup_theme', myquery_args );
出力箇所
<?php
$myquery_query = new WP_Query($myquery_args);
if($myquery_query->have_posts()): while($myquery_query->have_posts()): $myquery_query->the_post();
?>
header.php、footer.phpは関数をglobal宣言しないと使えないっぽい
<?php
global $myquery_args;//←これ
$myquery_query = new WP_Query($myquery_args);
if($myquery_query->have_posts()): while($myquery_query->have_posts()): $myquery_query->the_post();
?>