WordPress.org

Support

Support » Themes and Templates » How to get the post id BEFORE the_post() is invoked?

How to get the post id BEFORE the_post() is invoked?

  • I am using wordpress 2.2+

    I want to get the post id with PHP technical. However, when trying to get that via get_the_ID or $id, it works fine in sidebar.php and footer.php but NOT working in header.php

    I think that’s due to a invoking of “the_post”. I tested and found that if I put the the_post() in header.php it could really get the id. However, if I do so, something will be wrong and the post will be not shown.

    So is there anyway to get the id before invoking “the_post” in a header.php file?

    Thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to get the post id BEFORE the_post() is invoked?’ is closed to new replies.
Skip to toolbar