Changing the loop w/o killing category links

Okay, assuming you only want to restrict the categories for the front page, but still list all categories everywhere else, just add the according template file to your theme: front-page.php <?php get_header(); ?> <?php $my_query = new WP_Query(‘cat=79,120’); ?> <?php if ($my_query->have_posts()) : ?> <div id=”post-area”> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <div id=”post-<?php the_ID(); … Read more

display only parent replies count in index.php

Based on this answer I suggest the following code: // the theme’s functions.php /** * Get the number of top level comments for a post. * * @param int $post_id * @return int */ function wpse_95242_top_level_comments_for_post( $post_id = NULL ) { if ( NULL === $post_id ) $post_id = get_the_ID(); if ( ! $post_id ) … Read more

Pagination not working with custom loop

I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more