Exluding category from home.php – codex solution not working
-
Hello.
Firstly, I’m sorry if this isn’t in the correct forum, but I was not allowed to post in the ‘advanced’ forum.
On my site : https://www.berryconcept.co.uk/sandbox, I have a case-studies page which displays posts that are in the case-studies category. I do not want these posts displaying on any other page. In fact, I don’t want people to know they are posts at all, it is just an easy way to add case-studies. I have a template solely for the case-studies category.
Here is my case studies page:
https://www.berryconcept.co.uk/sandbox/category/case/On my home page (splash.php), I have a recent news section, and I have been successful in excluding the case studies category. The loop code on this page is:
<?php global $query_string; // required $posts = query_posts($query_string.'&posts_per_page=3'); // shows only three posts ?> <?php query_posts($query_string . '&cat=-19'); //excludes testimonials ?> <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> ...
I have then done the same for my news page (home.php) but this has not worked.
<?php if ( is_home() ) { query_posts($query_string . '&cat=-19'); } //excludes case studies from home page only ?> <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> ...
Any help would really be appreciated.
Also, is there any way of excluding a category from the category section on a widgetised sidebar without editing the wordpress files?
Thanks again.
- The topic ‘Exluding category from home.php – codex solution not working’ is closed to new replies.