• This has only happened since upgrading to 3.5 – but it is possible that it may have stopped working – however, I’m inclined to think it’s only happened since the upgrade.

    I have my index.php file below, which excludes all posts from categories 9-14 from being displayed on the blog page – unless they’ve been marked in cat 15 as well, which would then override this rule and show them on the blog page.

    However – this script is now showing ALL my blog posts on the blog home page – can you see what’s wrong with it?

    <?php get_header(); ?>
    
    <article class="main">
    <?php if ( have_posts() ): ?>
    
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    query_posts('posts_per_page=6&paged=' . $paged);
    ?>
    
      <?php get_sidebar(); ?>
        <div class="blogIndex">
          <h2>Latest Posts</h2>	
    
    <?php while ( have_posts() ) : the_post(); ?>
    
    <?php if( in_category('9,10,11,12,13,14') && !in_category('15') ) continue; //if it's category 9 or 11, but not in 15, continue
     ?>
          <article>
              <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
              <h2><a href="<?php esc_url( the_permalink() ); ?>" title="Click to view: <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
              <!--time datetime="<?php the_time( 'Y-m-d' ); ?>" pubdate><?php the_date(); ?><?php //the_time(); ?></time-->
              <?php the_excerpt(); ?>
              <p class="button"><a href="<?php the_permalink(); ?>">read full post</a></p>
            </article>
    
        <?php 
    
    /*      $i++;
          if ($i % 3) {
          // odd number
          } else {
          echo '<hr>';
          }
    */
        endwhile; ?>
      <?php if (  $wp_query->max_num_pages > 1 ) : ?>
              <div class="prevNext">
                <p class="nextPostsLink"><?php next_posts_link( __( '&larr; Older posts', 'twentyten' ) ); ?></p>
                <p class="previousPostsLink"><?php previous_posts_link( __( 'Newer posts &rarr;', 'twentyten' ) ); ?></p>
              </div>
      <?php endif; ?>
        </div> 
    
        <?php else: ?>
        <h2>No posts to display</h2>
        <?php endif; ?>
    
    </article>
    
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • Thread Starter tjobbe

    (@tjobbe)

    co-incidentally – my pagination fails on the very last link, taking me to “/blog/page/7/” and taking me to my 404 page.

Viewing 1 replies (of 1 total)
  • The topic ‘Why is my exclude categories script not working?’ is closed to new replies.