Why not reset wp_query?

How to reset the wp_query function when you click on the output headings ?

 $args = array(
 'post_type' =--> 'post',
 'meta_key' => 'post_price',
 'meta_query' => array(
 'key' => 'post_price',
 'value' => '0',
 'compare' => '>',
 'type' => 'NUMERIC',
 'order' => 'ASC',
 'suppress_filters' => false,
 'orderby' => 'meta_value_num',

 <?php $query = new WP_Query( $args ); ?>
 <?php if ($query--->have_posts()) { while ($query->have_posts()) {$query->the_post(); ?>

 <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
 <div class="catalogSec-Item">
 <div class="catalogSec-img">
 <?php the_post_thumbnail( 'thambnail' ) ?>
 <div class="catalogSec-descript">
 <p class="catalogSec-descript__name"><?php echo get_short_title(36); ?></p>
 <!-- <p class="catalogSec-descript__functional"><?php // the_category( $separator = '/', "); ?></p> -->
 <p class="catalogSec-descript__price"><?php the_field('post_price'); ?> RUB.</p>
 <div class="catalogSec-descript-btn">
 <a href="<?php the_permalink(); ?>" class="btn-blue catalogSec-descript__btn">Buy</a>

 <?php } // end while ?>
 <?php the_posts_pagination(); ?>
 <?php } wp_reset_query(); ?>
June 3rd 19 at 19:13
1 answer
June 3rd 19 at 19:15
The request does not specify the parameters for the product category. See The Settings Of The Taxonomies. Ie you need to opredeliti where you are, listed or not, and if you're in a category, then add query parameters to fetch posts from the current category.

However, since it is evident that all the salt that is in the price of goods, it is better modificirovat the main query WordPress comment-24037 only for the main query, the search now reports to the chief request.

And why check for a price greater than 0? You status to put a draft to write, if the price is equal to 0.
And what's a taxonomy? and how to modify the main query, do not understand(((( ? - devan24 commented on June 3rd 19 at 19:18
taxonomy = heading = taxonomy
You're trying to do the default behavior netandartny ways not. the query depending on the Column

query_custom_filter function( WP_Query $query ) {
 if ( ! is_admin() && $query->is_main_query() ) {

 $query->set( 'meta_query', array(
 'post_price' => array(
 'key' => 'post_price',
 'value' => '0',
 'compare' => '>'
 ) );

 $query->set('orderby', 'post_price');
 $query->set('order', 'ASC');

add_action( 'pre_get_posts', 'query_custom_filter' );

Next, create a template category.php and it display posts in a standard cycle.
The hierarchy of theme files (template) - santiago30 commented on June 3rd 19 at 19:21
It worked, perfectly. The current here has a new problem, now when I go to another page, writes in the header of the page not found and custom fields are not displayed what to do ?(( - devan24 commented on June 3rd 19 at 19:24
to understand why the page is not found. I think there is in terms of changes to the global query. Most likely it is necessary to add
! is_admin() && $query->is_main_query() && ! is_page()
ie change global request only where this is necessary. To check the availability of the necessary templates in the theme. - santiago30 commented on June 3rd 19 at 19:27
thank you very much! - devan24 commented on June 3rd 19 at 19:30

Find more questions by tags WordPress