Forums

[resolved] PHP Ifelse not working :( (4 posts)

  1. derekfreeze
    Member
    Posted 5 months ago #

    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.

  2. zoonini
    help me help you
    Posted 5 months ago #

    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.

  3. derekfreeze
    Member
    Posted 5 months ago #

    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!

  4. zoonini
    help me help you
    Posted 5 months ago #

    My pleasure. :-)

Reply

You must log in to post.

About this Topic