Single.php displays all posts
-
This is doing my head in, I just can’t figure out why my single.php page always loads 10 posts (as set by how many posts to display per page).
I’ve looked about online and found loads of soloutions and ideas and none seem to work for me. I’ve tried a query to set post display to 1, I’ve tried my own custom loops
if $i < 0
andwhile have posts & $i < 0
and still can’t beat it. I know its not issues from code blocks because I can remove calls to the header, footer and sidebar and it still displays incorrectly.Heres my current code
<?php /** * The Template for displaying all single posts. * * @package WordPress * @subpackage Bare * @since Bare 1.0 */ ?> <h1>Single.php</h1> <?php // Exclude posts with a category ID of 8 (My Work) query_posts('cat=-8'); if (have_posts()) while (have_posts()) : the_post(); ?> <div id="nav-above" class="navigation"> <div class="nav-previous"> <?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentyten' ) . '</span> %title' ); ?> </div> <div class="nav-next"> <?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentyten' ) . '</span>' ); ?> </div> </div><!-- #nav-above --> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h1 class="entry-title"><?php the_title(); ?></h1> <div class="entry-meta"> <?php posted_on(); ?> </div><!-- .entry-meta --> <div class="entry-content"> <?php the_content(); ?> <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?> </div><!-- .entry-content --> <div class="entry-utility"> <?php posted_in(); ?> <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?> </div><!-- .entry-utility --> </div><!-- #post-## --> <div id="nav-below" class="navigation"> <div class="nav-previous"> <?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentyten' ) . '</span> %title' ); ?> </div> <div class="nav-next"> <?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentyten' ) . '</span>' ); ?> </div> </div><!-- #nav-below --> <hr /> </br> <?php comments_template( '', true ); endwhile; // end of the loop. ?>
You might notice I’m excluding posts from a set category which works on the post display themselves, but the links still pick them up, is there anyway to prevent the links picking up these posts as well as get single.php to display just one post?
- The topic ‘Single.php displays all posts’ is closed to new replies.