[wordpress] カスタムフィールドが特定の値の投稿を取得する方法
カスタムフィールドが特定の値の投稿を取得する方法は以下の通り
$args = Array(
'post_type' => 'information',//informationのカスタムカテゴリ
'posts_per_page' => -1,//全件取得
'meta_key' => 'productid',//カスタムフィールドのKey
'meta_value' => '1111'//カスタムフィールドの値
);
$the_query = new WP_Query($args);
if($the_query -> have_posts()):
while($the_query -> have_posts()): $the_query -> the_post();
//ここに処理を記述
endwhile;
endif;
wp_reset_postdata();