Take the 2-minute tour ×

I have a blog (bernsteinbear.com) that uses the TwentyEleven theme. I'm trying to make a custom page template for the front page (a blog page) that gets all the posts except in the "Comic" category. I managed to do that, except the pagination got messed up... How could I exclude a category from the main blog, have it only on a separate page, and have pagination function correctly? I'm befuddled... Thank you!


EDIT: I have full SSH access to my server, and can edit anything. No restrictions.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try this code in your template.

 * Template Name: Exclude Comic Category
get_header(); ?>

    <div id="primary">
                <?php query_posts( array( 'category_name' => 'comic', 'paged' => get_query_var('paged'), 'posts_per_page' => 5 ) ); ?>
        <?php if ( have_posts() ) : ?>

            <?php twentyeleven_content_nav( 'nav-above' ); ?>



            <?php endwhile; ?>

            <?php twentyeleven_content_nav( 'nav-below' ); ?>

        <?php else : ?>

                <header class="entry-header">

                <div class="entry-content">
                    <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
                    <?php get_search_form(); ?>

        <?php endif; ?>

share|improve this answer
hmm in what context is this? maybe some more code? :-/ –  tekknolagi Nov 25 '11 at 7:02
Could I have a look at the query you are using to exclude your comics category? –  Joshua Abenazer Nov 25 '11 at 7:05
I forgot what that was; I deleted it while trying new things (from Google... :-/) but it was something along the lines of query_posts('cat' => '-81') where 81 is the comics category –  tekknolagi Nov 25 '11 at 7:07
you would need to add 'posts_per_page' => '5' to the query. Replace 5 with the number of posts you want to show. –  Joshua Abenazer Nov 25 '11 at 7:20
Ok my bad... that line needs to have the query inside an array if using that syntax. Put the updated answer and try. –  Joshua Abenazer Nov 25 '11 at 7:53

Your Answer


