wordpress カスタムフィールドパラメータ(値)で並び変える(sort)方法
wordpress カスタムフィールドパラメータ(値)で並び変える(sort)方法
これはカスタムフィールドの入力を数字にし、並び替えをしています。
<?php
$cost_args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_query' => array(
array(
'key' => 'car_sort_product',
)
)
);
$cost_box = get_posts($cost_args);
foreach ($cost_box as $post):
setup_postdata($post);
?>
<li>
<div class="right">
<h5 class="sub"><?php the_field('car_point_txt'); ?></h5>
<p class="car_text01"><?php the_field('car_describe'); ?></p>
<?php if (get_field('car_archive_price')): ?>
<p class="price_day"><?php the_field('car_archive_price'); ?></p>
<?php endif; ?>
<p class="more"><a href="<?php the_permalink(); ?>">詳細はこちら</a></p>
</div>
</li>
<?php endforeach; wp_reset_postdata(); ?>
参考サイト