WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
[resolved] Help with category condition (3 posts)

  1. mrbandit
    Member
    Posted 7 months ago #

    Hello all, I'm trying to add a simply conditional statement to my posts page and I'm not having any luck. I am doing a simple car site and cars listed are either in category "For Sale" or "Sold". I just want to display a sold image on the single post content view if the post is in the sold category. I've tried adding code to the class-content-post.php script,

    <p>Section1</p>
    	<?php if (is_category('sold')) : ?>
    	<p>This car has been sold</p>
    	<?php elseif (is_category('For Sale')) : ?>
    	<p>This car is still available</p>
    	<?php endif; ?>
           <p>EndSection1</p>

    I am going to replace the text with a img src html when I can get this worked out. Am I going about this wrong? Any help is appreciated.

  2. mrbandit
    Member
    Posted 7 months ago #

    Nevermind, I figured it out. I was in the right file, but not coding my syntax correctly.

    `<?php if (in_category('Sold')) { ?>
    THIS IS SOLD
    <?php } ?>`

    This is by far my most favorite theme yet!

  3. nikeo
    Member
    Theme Author

    Posted 7 months ago #

    Thanks for this feedback @mrbandit!
    Set as resolved.

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.