:)
我已经使用WP\\u Query在此处显示了这些帖子(旅行)http://boost19.delavec.si/wordpressP/produkti/
所以我有一个WP\\U查询,它在我的自定义帖子中循环
<?php $paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1; ?>
<?php $loop = new WP_Query( array(
\'post_type\' => \'product\',
\'meta_key\' => \'product_price\',
\'orderby\' => \'meta_value_num\',
\'order\' => \'ASC\',
\'posts_per_page\' => 4,
\'paged\' => $paged) ); ?>
<?php while( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="av_one_third" style="display: inline-block; width: 20%; margin-bottom: 3%; text-align: center; margin-left: 3%;">
<div class="card rounded-0 bg-light mb-3" style="width: 225px; height: 325px; text-align: center">
<h5 class="card-title"><?php the_title(); ?></h5>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<p>We are going to <?php the_field(\'product_place\'); ?></p>
<p>Product price: <?php the_field(\'product_price\'); ?>€</p>
<?php if(get_field(\'product_discount_price\')): ?>
<h4>Discount: <?php the_field(\'product_discount_price\'); ?>€</h4>
<?php endif; ?>
<p>We are going on <?php the_field(\'product_date\'); ?></p>
</div>
</div>
<?php endwhile; ?>
我希望添加类似“排序”的操作-我想知道是否可以将“order”更改为“DESC”作为初学者?我试过读不同的东西,比如https://premium.wpmudev.org/blog/building-customized-urls-wordpress/https://codex.wordpress.org/WordPress_Query_Vars
并尝试了这一点,但没有结果;
http://boost19.delavec.si/wordpressP/produkti/?order=DESC或http://boost19.delavec.si/wordpressP/?post_type=product&orderby=meta_value_num&meta_key=product_price&order=DESC
它不会返回应该返回的真值。
有人面对过这样的事情吗?或者,如果有人有任何其他想法,如何通过价格解决这类问题?
顺便说一句,我使用的是高级自定义字段-价格字段的名称是
产品价格