• Resolved derekfreeze

    (@derekfreeze)


    I’m working on a tweak for my company. I am trying to make an ifelse statement for this code.

    title="<?php the_title(); ?>"><?php the_title(); ?>

    The ifelse needs to make it so in place of the_title() is static text to display ‘view this devotional’ if a post is (in_category( ‘Devotions’ ) else display ‘View this post’.

    I am having trouble with it, if anyone could help me it would be greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Replace the second:

    <?php the_title(); ?>

    with:

    <?php
    if (in_category('Devotions')):
        echo "View this devotional";
    else:
        echo "View this post";
    endif; ?>

    Note: untested – please try on a test install first.

    Thread Starter derekfreeze

    (@derekfreeze)

    Thank you so much. Just want i needed. I was doing the exact code, but i was forgetting the : after the ))

    Thanks so much!!!

    May God Bless You!

    My pleasure. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP Ifelse not working :(’ is closed to new replies.