Support » Fixing WordPress » condtional for post title in sidebar

  • deepbevel

    (@deepbevel)


    I’m showing post titles in the sidebar (I have my reasons) but I only want them to show for specific categories. I don’t know how to apply conditional tags and I’m having a hard time figuring that out. Anyone?

Viewing 3 replies - 1 through 3 (of 3 total)
  • phe.le

    (@phele)

    Thread Starter deepbevel

    (@deepbevel)

    Thanks, I’ve been looking at that all day. But I’m unable to make it work.

    <?php if ( is_category('36,46) || is_archive() ) {
    	the_title();
    }  ?>

    I think I need more code, I don’t know how to tell it that it’s for the current post only, and I wouldn’t know how to add that to the equation anyway, I’d spend hours with trial and error.

    Thread Starter deepbevel

    (@deepbevel)

    It’s all good, I was going at it the hard way. Instead I removed:

    <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    From the custom post template I’m using, then I added:

    <div class="post" id="post-<?php the_ID(); ?>">
    <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    </div>

    to a php widget that I can add conditionals to. Works perfectly! Hopefully it won’t matter that I removed that title code, these are private posts, so search-engine-friendly is not a factor.
    Thanks for the link just the same.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘condtional for post title in sidebar’ is closed to new replies.