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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-09-2009, 08:08 AM   #1
Si
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
Si is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2009, 08:20 AM   #2
JamesK
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

Last edited by JamesK; 11-09-2009 at 08:22 AM..
JamesK is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2009, 08:20 AM   #3
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
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
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2009, 08:28 AM   #4
HowlingWulf
Confirmed User
 
HowlingWulf's Avatar
 
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;
}
__________________
WP Porn directory/review theme Maddos $35.

webmaster AT howling-wulf.com
HowlingWulf is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2009, 08:28 AM   #5
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,359
comon, give us a challenge :p

in the loop of course

Code:
<? echo $post->ID; ?>
or you could add it to functions.php in your theme

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
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2009, 08:29 AM   #6
Si
Such Fun!
 
Industry Role:
Join Date: Feb 2008
Posts: 13,900
Thanks guys, thats me sorted

Simple yet easy to miss.
Si is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-09-2009, 08:39 AM   #7
Si
Such Fun!
 
Industry Role:
Join Date: Feb 2008
Posts: 13,900
Quote:
Originally Posted by fris View Post
comon, give us a challenge :p
LOL its one of them things thats right in front of you yet you forget, but nevermind

Speaking of challenges, haven't had one of them with wordpress for a while so can't help you there
Si is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.