Wordpress : How do I subtract/disable a category on Index.php

Discussion in 'PHP' started by r_shahin, Oct 13, 2008.

  1. #1
    Okay guys, got another problem today, two, actually. Let's talk about the second one first. Now I know the following codes make WP display posts from Category-8 on the index_theme.php template and all other categories on Archive.php. My question is, what do I do if I need to display two categories on two different templates?? What if I want to use the index_theme.php for Category-8 and another new template- index_links.php - for another category, say, Category-9 and archive.php for every other categories?? These codes are for one single category, Category-8, but I need it to work for two categories. Can any one please help me out with this?
    <?php
    if (is_category(8)) {
       // looking for category 8 posts
       include(TEMPLATEPATH . '/index_theme.php');
    } else {
       // put this on every other category post
       include(TEMPLATEPATH . '/archive.php');
    }
    ?>
    Code (markup):
    Now, here's my first problem: how do I disable/subtract these two categories on Main page/index.php so that the main page doesn't show post from these two cats????

    I hope I'm making sense.
    Thank you~
     
    r_shahin, Oct 13, 2008 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    shallowink, Oct 13, 2008 IP
    r_shahin likes this.
  3. r_shahin

    r_shahin Peon

    Messages:
    306
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3

    Thanx shallowink! first problem solved!!

    I'm having some problem with my second problem though, I inserted your code like this:
    <?php
    if (is_category(8)) {
       include(TEMPLATEPATH . '/index_theme.php');
    } 
    elseif(is_category(7) {
       include(TEMPLATEPATH . '/index_portfolio.php');
    }
    else {
       include(TEMPLATEPATH . '/archive.php');
    }
    ?>
    
    Code (markup):
    but it returned with this error: Parse error: parse error, unexpected '{' in C:\EP\wp\wp-content\themes\baj\category.php on line 5
     
    r_shahin, Oct 13, 2008 IP
  4. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #4
    left off the second ) around the elseif

    elseif(is_category(7)) {
     
    shallowink, Oct 13, 2008 IP
  5. r_shahin

    r_shahin Peon

    Messages:
    306
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you once again Shallowink! It worked this time! Thank you!
     
    r_shahin, Oct 13, 2008 IP
  6. rishabh_destiny

    rishabh_destiny Active Member

    Messages:
    119
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #6
    I was having the same problem. Thanks for this thread
     
    rishabh_destiny, Jan 15, 2010 IP