Don’t nullify the main query, this breaks stuff. Also, avoid using the $wp_query
global as a custom variable. This breaks the main query and causes issues. You can also try adding 'suppress_filters' => true,
to your arguments to suppress any custom filters if you are using any custom filters.
Also, don’t use TEMPLATEPATH
, it is due to be depreciated according to a recent track ticket. Use get_template_part()
instead
Try the following
<?php // The Query
global $wp_query;
$term = $wp_query->queried_object;
$args=array(
'meta_key' => 'views',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'posts_per_page' => 5,
'post_type' => 'post',
'suppress_filters' => true,
'tax_query' => array(
array(
'taxonomy' => $term->taxonomy,
'field' => 'slug',
'terms' => $term->slug,
)
)
);
$new_query = new WP_Query($args);
while ($new_query->have_posts()) : $new_query->the_post(); ?>
<?php get_template_part( category-slider ); ?>
<?php
endwhile;
wp_reset_postdata(); ?>
Apart from this, everything should work, except if you are using query_posts
somewhere on the page which will break everything