WordPress.org

Ready to get started?Download WordPress

Forums

Category header for individual posts (3 posts)

  1. GATEKeeper
    Member
    Posted 6 years ago #

    Looking to insert a bit of code into my "single" template page to show custom titled headers for every category (i.e. "category-13"), so how would I make that work in an if statement?

    The idea I had that doesn't work is:

    <?php if ( in_category('category_id') ): ?>
       include(TEMPLATEPATH . '/single-'category_id'.php');
    <?php endif; ?>

    Any help would be vastly appreciated.

  2. mjg
    Member
    Posted 6 years ago #

    I created new header files called header2.php, etc and used this code to call the header for each category template:

    <?php include (TEMPLATEPATH . '/header2.php'); ?>

    What I haven't figured out yet is how to have the category header display on category posts. Anyone?

  3. mjg
    Member
    Posted 6 years ago #

    To answer my own question, the custom post templates plugin does the trick.

Topic Closed

This topic has been closed to new replies.

About this Topic