WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. klevismiho
    Member
    Posted 3 years ago #

    I put this code in the loop:

    <?php
    $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. alchymyth
    The Sweeper & Moderator
    Posted 3 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
    Member
    Posted 3 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

Tags

No tags yet.