Converting multiple loops into one single loop with pagination

You can refer this. Use the examples part. Inside the foreach loop put your all the code which needs to be repeated for each category type. something like: <?php $categories = get_the_category(); if($categories){ foreach($categories as $category) { $my_query = new WP_Query(‘cat=$category->term_id’); //code to display category posts goes here } } ?> You are ready to … Read more

Pagination working everywhere but the index page

Using Milo’s suggestion in the comments above fixed the issue. Using pre_get_posts we modify the loop like so. function filter_main_query( $query ) { if( is_front_page() && is_main_query() ) { $query->set(‘meta_key’, ‘rating’); $query->set(‘meta_value’, 0 ); // rest of params } } add_action(‘pre_get_posts’, ‘filter_main_query’, 9999);

Implementing an OR statement to wordpress wp_query

You can run two queries and merge the results: $cat_query_args = array( ‘paged’ => $paged, ‘order’ => ‘DESC’, ‘meta_key’ => ‘android_link’, ‘post_type’ => array( ‘post’, ‘app’ ), ‘cat’ => ’63’, ); $meta_query_args = array( ‘meta_query’ => array( array( ‘key’ => ‘android_link’, ‘compare’ => ‘EXISTS’, ) ) ); $cat_query = new WP_Query( $cat_query_args ); $meta_query = … Read more

Page navigation doesn’t show when query category

I found a partial workaround. Since the query object in the index.php is the right one I transferred it using serialize to template of choice, in this case category-video.php. In index.php i put on top <?php $s = serialize($wp_query); file_put_contents(‘query’,$s); ?> and in category-video.php I put <?php $u = file_get_contents(‘query’); $wp_the_query = unserialize($u); ?> It’s … Read more

When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?

You want to make sure you’re only messing with the main query and not subsequent queries called from a plugin or in a template on the search page. In other words… if( !is_admin() && $query->is_search ) { should be if( !is_admin() && $query->is_search && $query->is_main_query() ) { See http://codex.wordpress.org/Function_Reference/is_main_query

How to show in search results posts with a particular tag in a particular category?

Given the way categories & tags are setup in WordPress this would not work from a logical standpoint. The issue here is that tags have no way to be connected directly to a category, they are mutually exclusive from each other. The subcategories would work because a subcategory is directly related to is parent category … Read more