Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

Max

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

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Try this code in your template.

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

    <div id="primary">
       <div id="content" role="main">
                <?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 while ( have_posts() ) : the_post(); ?>

                <?php get_template_part( 'content', get_post_format() ); ?>

            <?php endwhile; ?>

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

        <?php else : ?>

            <article id="post-0" class="post no-results not-found">
                <header class="entry-header">
                    <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
                </header><!-- .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(); ?>
                </div><!-- .entry-content -->
            </article><!-- #post-0 -->

        <?php endif; ?>

        </div><!-- #content -->
    </div><!-- #primary -->
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
1  
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
1  
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
show 16 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.