Support » Themes and Templates » displaying current category

  • Resolved startribe

    (@startribe)


    Hey Group,

    I am trying to get my H2 to display the name of the category page, i.e., the name from the selected category-“X”.php. I was working from this document:
    http://codex.wordpress.org/Category_Templates

    and I was using this code:


    <?php if ( is_category() ) : ?>
    <h2 class="header2">
    <?php add_filter('category_description', 'wpautop'); ?>
    <?php add_filter('category_description', 'wptexturize'); ?>
    <?php echo $cache_categories[$cat]->cat_name ?>
    <?php echo category_description(); ?>
    <?php endif; ?>
    </h2>

    Any help would be greatly appreciated,
    Thanks,
    Orion

Viewing 8 replies - 1 through 8 (of 8 total)
  • Ummm… why is all the stuff in the H2?

    Wouldn’t it look more like:

    <h2><?php is_category(); ?></h2>
    Then the other stuff.

    And perhaps you need to echo the is_category(), I’m not sure.

    Thread Starter startribe

    (@startribe)

    Hey Leovenous,

    Thanks for the heads up on the H2, I wasn’t seeing it in comparison to the header through the preview, so I was bypassing it all together.

    That solution didn’t go through. It is the strangest thing, I am able to display the category description, but not the category.

    I could work around by throwing the title into the description, but I am doing my best to stick to semantics.

    Thanks for the reply, if you think of anything else, please share.

    All the Best,
    Orion

    Thread Starter startribe

    (@startribe)

    Beautiful!!!

    It worked, thanks Moshu.

    Now is there a way to put a conditional circumstance so that if it is the homepage (or not a category page) it displays a different text. Just pointing me in a direction would be great.

    Thanks for your help!

    All the Best,
    Orion

    Ooh, I know this one. Check out this page http://codex.wordpress.org/The_Loop_in_Action , scroll way down to “Static Front Page” and check out the “is_home” tag.

    Thread Starter startribe

    (@startribe)

    Wow! Thank you both, I will give it a try when I get a chance, may be a couple of days now cause of other projects. But thank you very much!

    All the Best,
    Orion

    Thread Starter startribe

    (@startribe)

    I did it!!! With the help of the community of course. I am now running off of the index.php with includes and and conditional tags, and all headers and secondary navs are set through conditions.

    Thank you so much. All I have left is checking the layout across browsers, I am only off of a mac with firefox, and I haven’t adjusted for the box issue as of yet.

    Alright Moshu and Leovenous,
    Thank you so much for your help,
    All the Best,
    Orion

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘displaying current category’ is closed to new replies.