WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Page condition grouped on category (3 posts)

  1. BlueDot
    Member
    Posted 5 years ago #

    I am a wordpress convert. I love it's simplicity compared to the Postnuke I used to develop with. Currently, I am moving 10 years of static content to a new WordPress site.

    I would like to place a conditional statement in my header.php file as such:
    <?php if ( is_category(stories) ) { include ('header-stories.php'); } ?>

    But this only works when a category is called in the URL. I would like every post that is within this category to show the alternate header. All story posts, no matter how they are called, by category or by single.php should bear the story header.

    I have too many stories to post as 'posts' to do if_post(array()) conditions, as there are hundreds. I need to group them by category.

    This must be possible... right?

  2. BlueDot
    Member
    Posted 5 years ago #

    I found my answer. The key was to implement the category.php and tag.php templates. I then add a simple loop looking for tags, pages or categories based on being in the respective templates.

    We now have dynamic headers based on pages, categories, single posts and tags! Woohoo!

  3. tommangatt
    Member
    Posted 5 years ago #

    hi bluedot,
    could you please explain this in detail, as a newbie can understand?
    thanks in advance
    tom

Topic Closed

This topic has been closed to new replies.

About this Topic