• How the heck does one retrieve the current page ID?? I would like to use it in the body tag in my header to set an ID for current menu item since I cannot get that to work for all the blogs subpages..

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter scooby

    (@scooby)

    Well I don’t think that will get what I’m trying to do here.. Im trying to get the main menu to highlight when going into the comments on a post.. Say I have a page named blog that shows all posts.. That page is now the current_page_item and works great.. The problem Im trying to solve is when you click to view the comments on a particular post.. The main blog link is no longer the current_page_item and I would like it to be.. Is there a possibilitly to get this to work.. I’m pretty stuck now..

    Thread Starter scooby

    (@scooby)

    Would anybody know how to do the following?? I’m trying to get the actual page id and not the post id..

    This is what works for the post id:

    echo $post->ID;

    I’m trying to get something like this to work:

    echo $page->ID;

    Any ideas out there??

    Actually I believe it is just $post->ID, if you dig into the docs you’ll discover that the post table is used to store posts, pages, and attachments.

    And you can also use the template tag the_ID() instead.

    See the docs: http://codex.wordpress.org/Template_Tags

    You might also find these conditional tags helpful:
    http://codex.wordpress.org/Conditional_Tags

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get the current page ID??’ is closed to new replies.