• Resolved whiteh

    (@whiteh)


    Hey guys. I’m building my own theme for WordPress, and am still a bit new to this so I need a bit of help πŸ˜€

    I have a feature I built into the template that allows the user to email the current page to a friend, it’s a plugin, and the way it works is collecting the User ID and sending them to another page like:

    http://domain.com/email/?id=5

    It works, but I want to have the same thing happening somewhere else on the template, hence I need to copy what the plugin does and put it in a new a tag if you know what i mean. Problem is the plugin uses PHP for everything and I can’t for the life of me see how it gets the post ID.

    SO, if anyone knows how I can get the post id (not the permalink) for the current post I’d be extremely grateful πŸ™‚

    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Most times it is $post->ID or might try $id.

    Thread Starter whiteh

    (@whiteh)

    THANK YOU! πŸ˜€

    echo $id

    ^ works like a charm πŸ˜€

    I’m using WordPress 2.7.

    I’m following the instructions http://codex.wordpress.org/Template_Tags/wp_list_pages

    but the $post->ID is returning a number that doesn’t work β€” actually a revision instead of the original post. THe original was id=33 (I checked the DB).

    There was a revision ID=151 – and this is the number $post->ID gives me.

    However, using wp_list_pages(“child_of” . $post->ID) doesn’t work. While it should return 151 because that is the last revision, WP doesn’t think that 151 has any child pages, because it doesn’t list anything.

    What am I missing? I didn’t think it would be that hard to list sub pages.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Getting post ID using function’ is closed to new replies.