WordPress.org

Support

Support » How-To and Troubleshooting » Hot to get the post ID within the loop?

Hot to get the post ID within the loop?

  • 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?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hot to get the post ID within the loop?’ is closed to new replies.
Skip to toolbar