Answer the question
In order to leave comments, you need to log in
How to get max and min value from WP_Query?
Can you tell me how to get MAX and MIN values from an array of records? I have posts belonging to one category, there is a catalog page where all posts of this category are displayed with pagination. The uploaded records, I want to sort by the values of arbitrary fields, using ACF. For example, by price and diagonal.
Example:
<?php $query = new WP_Query( $args );
while (have_posts()) : the_post(); ?>
<div class="tovar">
<a href="<?php the_permalink() ?>"><h2><?php the_title(); ?></h2></a>
<p>Цена: <strong><?php the_field('price'); ?></strong></p>
<p>Диагональ: <strong><?php the_field('char'); ?></strong></p>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php echo paginate_links( $args ) ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question