Hot to get the post ID within the loop? (3 posts)

  1. klevismiho
    Posted 5 years ago #

    I put this code in the loop:

    $post_id = $post->ID;
    echo $post_id;

    and it gives me this error:
    Parse error: syntax error, unexpected T_VARIABLE

    If I don't echo the variable, it doesn't display any errors.
    Any idea?

  2. Michael
    Forum Moderator
    Posted 5 years ago #

    can you paste the full code of your loop into a http://pastebin.com/ and post the link to it here?

  3. klevismiho
    Posted 5 years ago #

    Never mind, was a problem of character encoding.
    Thank you for trying to help.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.