• Resolved schlobben

    (@schlobben)


    I have searched over and over, so I finally gave up. Anyone know how to get the post id, using the_ID() without having it printed out?

    I need it to make a navigation where the active post is highlighted by comparing the post I am reading with the ID’s of the posts in the menu.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The global variable $id should have it.. all the_ID() does is:

    global $id;
    echo $id

    function get_the_id() {
    global $id;
    return $id;
    }

    Thread Starter schlobben

    (@schlobben)

    Thank you for that ultra fast reply, and how easy can it be! This should be mentioned in the template tags next to the_ID(), guess it’s more ppl than me that has been looking for it!

    $id was exactly what I needed!

    Thanks!

    $post->ID

    $post is an object which contains all data about a post directly from the database. There’s also $comment.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get the_ID() as variable’ is closed to new replies.