Exclude posts from certain category on blog only
-
I have a custom home page set up and a blog section which currently shows all posts.
I’d like to exclude ALL posts from category id 9 from showing on the blog page (unless they’ve been assigned to category 9 and another special category which would override this).
Is this possible? I came across this page but I couldn’t get it to work: https://codex.www.ads-software.com/The_Loop
Here’s my current index.php file (note, this is not my home page)
<?php get_header(); ?> <article class="main"> <?php if ( have_posts() ): ?> <?php get_sidebar(); ?> <div class="blogIndex"> <h2>Latest Posts</h2> <?php while ( have_posts() ) : the_post(); ?> <article> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a> <h2><a href="<?php esc_url( the_permalink() ); ?>" title="Permalink to <?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; ?> </div> <?php else: ?> <h2>No posts to display</h2> <?php endif; ?> </article> <?php get_footer(); ?>
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Exclude posts from certain category on blog only’ is closed to new replies.