Forums

in_category: Trying to not display content in subcategories... How? (4 posts)

  1. ttomp13
    Member
    Posted 1 year ago #

    Hey Everyone.

    I'm hoping that someone will be able to help me out.

    Basically, I'm using the following code to display specific videos in specific categories:

    <?php if (in_category ('Football News') ): ?>
    FOOTBALL VIDEO
    <?php endif; ?>

    Problem is, the above code is displaying the football video in all of the child categories as well.

    If possible, I would like to display the FOOTBALL VIDEO in only the FOOTBALL NEWS category, and no subcategory.

    Is this possible?

    Thanks so much for the help.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Your logic is correct but it really depends where you're using this code...

  3. threestyler
    Member
    Posted 1 year ago #

    You could try including cats by id or excluding cats by id:

    <?php query_posts($query_string . '&cat=3'); ?>
    <?php query_posts($query_string . '&cat=-3,-4,-65'); ?>

  4. ttomp13
    Member
    Posted 1 year ago #

    I tried copying your code directly, but it didn't work. I'm extremely new to PHP... Managed to get my site looking nice though.

    LOL

    Anyway, I'm okay with moving pieces of code, and fiddling with things, so I will continue to fiddle.

    I'll do more research on the code you're providing.

    Anyone have any other suggestions?

Topic Closed

This topic has been closed to new replies.

About this Topic