Reputation: 747
How to get the page id in wordpress in the case of friendly url?
Upvotes: 1
Views: 1739
Reputation: 52655
If you are within the Loop (most of the time meaning within the while(have_posts())
you should be able to use: global $post; $id = $post->ID;
to get the ID
Upvotes: 0
Reputation: 298582
I'm guessing you're talking about doing it via the Admin interface. Can't you just add it into the custom format
textbox using the %post_id%
string:
/archives/%post_id%
Upvotes: 0
Reputation: 3581
Inside the Loop: http://codex.wordpress.org/Function_Reference/the_ID
Outside the Loop: global $wp_query; $id = $wp_query->post->ID;
Upvotes: 2