Forums

Get the id (2 posts)

  1. milardovich
    Member
    Posted 2 years ago #

    Hi!,
    I'm at the final phase of developing a plugin but I have a problem: I can't get the id of the current post. And I couldn't found any functions to get the id OUTSIDE the loop (get_the_ID doesn't work in this case). Any suggestions?. Thanks.

  2. songdogtech
    Member
    Posted 2 years ago #

    Inside the loop:

    <?php $wp_query->post->ID; ?>

    Outside the loop:

    <?php $post_id = $wp_query->post->ID; echo $post_id;?>

Topic Closed

This topic has been closed to new replies.

About this Topic