![]() |
How can I grab th post ID from my wp blog, without changing the htaccess?
I need to grab my post ID number from some of my blog posts for this plugin I'm trying to configure and can't think how to do it without changing my htaccess backwards and forwards.
for example, urloftheblog.com/post-name-is-here/ I need the /?p=22 but without having to change the htaccess everytime It's fine at the moment because the blog is new and ain't got to worry about fucking anything up but I'd rather know a way to do it in the future. If that makes sense and I didn't confuse you, please :helpme Thank you :thumbsup |
You can look it up from the admin panel. Mouseover the post links and you'll see the ID's.
Another option is to modify the template slightly and put the post ID in a HTML comment (for example <!-- ID -->) so you can view it from the source. You can see the ID tag and how to call it in your templates here: http://codex.wordpress.org/Template_Tags/get_posts You could even make it so only logged in admins could see it. |
in /wp-admin/ go and edit the post
it will look like: wp-admin/post.php?action=edit&post=435 post=xxx its your id |
If it's a wordpress plugin just use the wordpress functions to get the id in or out of the loop. A google search will show you how.
If you need to use the url then try function get_post_by_title($page_title, $output = OBJECT) { global $wpdb; $post = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='post'", $page_title )); if ( $post ) return get_post($post, $output); return null; } |
comon, give us a challenge :p
in the loop of course Code:
<? echo $post->ID; ?> Code:
function print_postid() { |
Thanks guys, thats me sorted :thumbsup
Simple yet easy to miss. :) |
Quote:
Speaking of challenges, haven't had one of them with wordpress for a while so can't help you there :upsidedow |
All times are GMT -7. The time now is 07:56 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123