WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Checking value of meta data and returning post differently styled (3 posts)

  1. SteelFrog
    Member
    Posted 4 years ago #

    I'm running (or rather, trying) the following script to check whether the meta data "full" has a value and return the post's content differently.

    <?php if (have_posts()) :
        while (have_posts()) : the_post();
             $customField = get_post_custom_values("full");
           	 if (isset($customField[0])) {
                  //Custom field is set, display a full post
                  the_title();
                  the_content();
             } else {
                  // No custom field set, let's display an excerpt
                  the_title();
                  the_excerpt();
        endwhile;
    endif;
    ?>

    However, this generates the following error and I can't seem to figure out why. I'm having a hard time understanding why.

    Parse error: parse error, unexpected T_ENDWHILE

  2. Mark / t31os
    Moderator
    Posted 4 years ago #

    Missing a closing curly bracket after the else...

    Just need to close that else condition before the endwhile and it'll get rid of the error... ;)

  3. SteelFrog
    Member
    Posted 4 years ago #

    Ugh. You were right, that's all that was missing. Thanks a bunch!

Topic Closed

This topic has been closed to new replies.

About this Topic