WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Code verification (9 posts)

  1. Jay
    Member
    Posted 2 years ago #

    Im trying to display the content if it is available and if not it displays "more info coming soon"

    Is this right? It works, I just want to make sure it is the correct way and most efficient.

    <?php if($content = $post->post_content ) {
      echo "<span class='titles'>Description:";
      echo "</span>";
      echo the_content();
    } else {
     echo "<span class='titles'>More Info Coming Soon</span>";
    } ?>

    thanks

  2. Jay
    Member
    Posted 2 years ago #

    does this mean its right?

  3. Tim S
    Member
    Posted 2 years ago #

    The code looks clean, if it works then I'd say use it. Every developer codes differently, but your code looks clean.

  4. Jay
    Member
    Posted 2 years ago #

    Thank you!

  5. Tim S
    Member
    Posted 2 years ago #

    No worries! Take care!

  6. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    This is wrong syntax:

    if($content = $post->post_content )

    You're setting $content equal to $post->post_content, and thus your conditional will always be true.

    Try this instead:

    if( $content == $post->post_content )
  7. Tim S
    Member
    Posted 2 years ago #

    Chip good catch! I should've caught that earlier!

  8. Jay
    Member
    Posted 2 years ago #

    I changed it to this

    if($content = $post->post_content !='' )

    Thanks!

  9. Jay
    Member
    Posted 2 years ago #

    and now this

    if($post->post_content !='' )

Topic Closed

This topic has been closed to new replies.

About this Topic