WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Need help on If and Else statements. (3 posts)

  1. letusrise
    Member
    Posted 3 years ago #

    Hello, everyone.

    I am new to this WordPress Support Community. Its been hours tweaking this code. Well, my coding background is not quite good so I really need your help guys.

    `<?php
    $category = get_the_category();
    $cat_slug = $category[0]->category_nicename;
    query_posts(array(
    'name' => $cat_slug,
    ) );
    if (have_posts()) : while (have_posts()) : the_post();
    the_content();
    endwhile;
    endif;
    wp_reset_query();
    ?>`
    BTW, the codes call a post then it will be displayed in the category.

    Well, the code works but I want to put a code if there is nothing to call it will return to echo 'This will be updated.'

    Thanks so much guys!
    God Bless!

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    from this:

    endwhile;
    endif;

    to this:

    endwhile;
    else:
    echo 'This will be updated.';
    endif;
  3. letusrise
    Member
    Posted 3 years ago #

    Wow, thanks so much bro.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.