![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Such Fun!
Industry Role:
Join Date: Feb 2008
Posts: 13,900
|
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 ![]() Thank you ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
hi
Industry Role:
Join Date: Jun 2002
Posts: 16,731
|
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.
__________________
M3Server - NATS Hosting |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Nov 2001
Posts: 1,662
|
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; } |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,359
|
comon, give us a challenge :p
in the loop of course Code:
<? echo $post->ID; ?> Code:
function print_postid() { global $post; $postid = $post->ID; return $postid; } ![]()
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Such Fun!
Industry Role:
Join Date: Feb 2008
Posts: 13,900
|
Thanks guys, thats me sorted
![]() Simple yet easy to miss. ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Such Fun!
Industry Role:
Join Date: Feb 2008
Posts: 13,900
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |