Nesting Echo’s or output variable differently?

I am trying to check to make sure a custom-field is not blank before echoing the custom-field.

This is what I have

Read More
<?php 
  $key = 'one_line_summary'; 
  $themeta = get_post_meta($post->ID, $key, TRUE); 
  if($themeta != '') {
    echo '<blockquote><?php echo get_post_meta($post->ID, one_line_summary, true); ?></blockquote>';
  }
?>

But it out puts the “get_post_meta($post->ID, one_line_summary, true);” literally rather than the contents of the variable one_line_summary.

I am a beginner but I feel like I need to either use nested echo’s somehow or change the second echo all together?

Thanks in advance.

Related posts

Leave a Reply

1 comment

  1. You have nested <?php ?> inside an existing set of PHP tags, which is not allowed. Remove those, and concatenate in the function call to get_post_meta(). What happened here is that the inner <?php ?> tags were output as strings to the browser, but not rendered onscreen (since the browser treated them as unknown HTML tags).

    echo '<blockquote>' .  get_post_meta($post->ID, one_line_summary, true) . '</blockquote>';
    

    As a note, these kinds of issues are considerably easier to spot with proper code indentation as was done when your post was edited above.