いつもお世話になっております。
taxonomy-AAA_tag.php
メインループで投稿を1件出力しています。
その下にタグアーカイブ(同じタグを持つ投稿)を全件表示し、並び方の条件として、ACF(Advanced Custom Fields)で作成したカスタムフィールド(price)の数値で安い順に出力をしたいです。
下記のサブクエリでは、並び方は安い順で表示がされていますが、
同じタグを持つという条件が一切無視され、すべての投稿が出力されます。
php
1<?php 2$args = array( 3 'post_type' => 'AAA', 4 'posts_per_page' => -1, 5 'meta_key' => 'price', 6 'orderby' => 'meta_value_num', 7 'order' => 'ASC', 8 ); 9$the_query = new WP_Query($args); ?> 10<?php if ($the_query->have_posts()) : 11 while ($the_query->have_posts()) : $the_query->the_post(); ?> //相違点 12<div>ループの内容</div> 13<?php endwhile; endif; wp_reset_postdata(); ?>
下記のように記述すると、同じタグを持つ投稿が出力されますが
並び方が無視され、さらに全件表示もされず、条件がすべて無視されてしまいます。
php
1<?php 2$args = array( 3 'post_type' => 'AAA', 4 'posts_per_page' => -1, 5 'meta_key' => 'price', 6 'orderby' => 'meta_value_num', 7 'order' => 'ASC', 8 ); 9$the_query = new WP_Query($args); ?> 10<?php if(have_posts()): while(have_posts()): the_post(); ?> //相違点 11<div>ループの内容</div> 12<?php endwhile; endif; wp_reset_postdata(); ?>
行き詰まっており、目的とする形が実現できません。
どなたかご教授をいただければと存じます。
何卒よろしくお願い申し上げます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。