[wp-hackers] get post Id from url (when mod_Rewrite enabled)

Alexander Concha alex at buayacorp.com
Thu Dec 27 12:36:27 GMT 2007

Vladimir Ghetau escribió:
> Hi guys and Merry Christmas,
> I'm using an action hook 'init', that will try to get the post ID based
> on the specific URL that's being visited by the user.
> When no url rewriting is used, I can grab the post id using $_GET['p'].
> However, when URL , rewriting is in use, and I use the post_name slug
> line inside the link, I can't grab the post id at all. I tried to play
> with the WP_rewrite class, and nothing. I also did a print_r($_GET) and
> no slug shows up (thinking I'll do a MySQL select to extract my id).

Use url_to_postid function.

Alexander Concha

La risa sirve para poner distancia entre nosotros y algún suceso, lidiar
con él y dar vuelta la hoja.
		-- Bob Newhart.

More information about the wp-hackers mailing list