Forums

[resolved] Pages are being categorized! (6 posts)

  1. barmin
    Member
    Posted 5 years ago #

    I'm using the following script to customize the content of the sidebar:

    <?php if ( in_category(4) ) {

    // some php includes

    } else {

    //some else php includes

    }
    ?>

    The thing is, when I come to a PAGE, the script prints the output for 'if ( in_category(4) )', showing the exclusive content.

    Why does this happen? How do I fix it? Since pages have no categories, it should print the ELSE's output.

    For a second category exclusive content, should I just replace the ELSE for an ELSEIF, like this?

    <?php if ( in_category(4) ) {

    // some php includes for cat. 4

    } elseif ( in_category(2) ) {

    //some else php includes for tat. 2

    }
    ?>

  2. moshu
    Member
    Posted 5 years ago #

    1. While practically Pages cannot be categorized - for internal technical reasons they are always assigned to the "default" category of your blog (which seems to be be #4; or it was at the time of the creation of those Pages).

    2. Actually, the reason Pages being displayed where only posts are expected - might be caused by the new DB structure. Read:
    http://www.transycan.net/blogtest/2007/01/23/how-pages-are-different-in-wp-21/

  3. barmin
    Member
    Posted 5 years ago #

    So, I should create a new category "Pages", and assing the pages to it, by editing the DataBase... It should work, doesn't it?

    BTW, I'm using WP 2.0, not 2.1

  4. barmin
    Member
    Posted 5 years ago #

    Worked fine. DB hack.

    Now I need some help with se 2nd part of this mess:

    http://wordpress.org/support/topic/103638?replies=3

  5. Otto
    Tech Ninja
    Posted 5 years ago #

    You could do something like this:
    <?php if (is_page())
    {
    // page stuff
    } elseif ( in_category(4) ) {
    // some php includes for cat. 4
    } elseif ( in_category(2) ) {
    //some else php includes for tat. 2
    }
    ?>

    Or something similar.

  6. barmin
    Member
    Posted 5 years ago #

    Duh... didn't think about it. It would have worked too.

    Otto42, could you please help me with the other topic that's bugging me?

    http://wordpress.org/support/topic/103638

Topic Closed

This topic has been closed to new replies.

About this Topic