• 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 : http://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:
    http://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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You need to make the changes in your theme’s index.php template file. Get rid of the home.php file.

    Thread Starter tjphop

    (@tjphop)

    Ok, I have removed home.php and instead am now using index.php. But still no luck. Here is my index.php:

    http://pastebin.com/uQw3WLWG

    Thanks

    Dos your site use a static front page?

    Thread Starter tjphop

    (@tjphop)

    Yes it does. The page name is Home but it uses a page template splash.php

    Try removing the if ( is_home() ) conditional.

    Thread Starter tjphop

    (@tjphop)

    No, that doesn’t work unfortunately 🙁

    Thread Starter tjphop

    (@tjphop)

    No, that doesn’t work unfortunately 🙁

    I also tried adding something to show only 3 posts, but that also didnt do anything.

    <?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 ?>
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Exluding category from home.php – codex solution not working’ is closed to new replies.