Support » Themes and Templates » Global $post not echo'ing in p tag

  • Hello I am using the $post to echo the content of a page for a bio.

    My code is:

    <?php global $post ?>
    <h3><? echo $post->the_title; ?>
    <p><? echo $post->the_content; ?></p>

    The title renders correctly in the h3 tag but the content is echo’ing outside of the p tags. Any suggestions?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator stephencottontail

    (@stephencottontail)

    May I ask why you aren’t simply calling the_title() and the_content()? You can run the loop on any page and simply limit the query to posts by that author.

    Also, shouldn’t you call $post->post_title and $post->post_content instead?

    Sorry… I am calling the

    $post->post_title & $post->post_content

    but the content is in not rendering inside the p tag. I want to create a generic bio page that any one can use with out necessarily having to be an author.

    Moderator stephencottontail

    (@stephencottontail)

    Can you post the output of var_dump( $post->post_content )? It should just be a string.

    output is string(3282)

    Moderator stephencottontail

    (@stephencottontail)

    I’m sorry, but I can’t seem to reproduce your issue. When I input the same code in my local WP install, I get the contents of each post output correctly between <p> tags. Also, don’t forget to close your <h3> tag after the title.

    Thank you for the help

    Moderator stephencottontail

    (@stephencottontail)

    One more thing I thought of. Can you post the HTML output of your PHP code?

    Moderator Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Maybe your server doesn’t support PHP opening short-tags?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Global $post not echo'ing in p tag’ is closed to new replies.