Forums

[resolved] Usingin in_category on single.php to show content based on category (3 posts)

  1. lalindsey
    Member
    Posted 1 year ago #

    Ok, what I want to do is pretty simple (I think) - but I'm tired and it's late and I can't wrap my head around at the moment:

    Ok, what I want to do is on the single post page I want to use in_category to determine if the post is in a certain category and if it is in that category I want it to show a link that is populated by custom values.

    Basically without the in_category conditional this is what the code looks like:

    <a href="<?php $URL= get_post_custom_values('URL'); echo $URL[0]; ?>"><img src="<?php bloginfo('template_url'); ?>/images/go.gif" alt="Go <?php the_title(); ?> Now" /></a>

    So what I want to do is wrap that in a conditional testing if it is in a specific category (and if it is I want the above to display, if not, show nothing). What I can't figure out is how to convert the current php items so I can pass it through the conditional. I know I have to strip out the <?php & ?> and what not, but when I tried it several different ways I keep getting errors.

    Thanks,
    Lindsey

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    do you mean:

    <?php if( in_category('blabla') ) : ?>
    <a href="<?php $URL= get_post_custom_values('URL'); echo $URL[0]; ?>"><img src="<?php bloginfo('template_url'); ?>/images/go.gif" alt="Go <?php the_title(); ?> Now" /></a>
    <?php endif; ?>
  3. lalindsey
    Member
    Posted 1 year ago #

    Yep, that's exactly what I meant. I figured it out when I woke up this morning. Next time I'll nap first.

Topic Closed

This topic has been closed to new replies.

About this Topic