Query posts by views on category page

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 … Read more

Show Top 10 posts in a rss feed

You could do it by overriding the main query results if there is a querystring detected in the feed URL eg. ?top_ten Add a query variable for the top ten: function my_query_vars( $query_vars ) { $query_vars[] = ‘top_ten’; return $query_vars; } add_filter( ‘query_vars’, ‘my_query_vars’ ); Create a function for your code to retrieve the top … Read more

wp query for popular post with simple field

The correct query is: $args1 = array( ‘showposts’ => 5, ‘ignore_sticky_posts’ => 1, //ORDER ARGUMENTS ‘meta_key’ => ‘post_views_count’, ‘orderby’ => ‘meta_key_num’, ‘order’ => ‘DESC’, //META QUERY ‘meta_query’ => array( array( ‘key’ => ‘_simple_fields_fieldGroupID_2_fieldID_1_numInSet_0’, ‘compare’ =>’NOT EXISTS’ ), ), ); $popularposts = new WP_Query($args1); The order aguments are always outside meta_query, see the codex.

Display most popular posts of category

How about adding ‘cat’=> 10 to your query? $new_query = new WP_Query( array( ‘posts_per_page’ => $carousel_count, ‘meta_key’ => ‘wpb_post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘monthnum’=> $month, ‘year’=> $year, ‘cat’=> 10 ));

Show popular post by category code

You are running two queries in one. You should only run one, and definitely not with query_posts. You should never ever use query_posts Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)