Kommentarer till WordPress – Get ID by post or page name https://www.jenst.se/2008/03/17/wordpress-get-id-by-post-or-page-name/ En WordPressblogg till Wed, 13 Mar 2013 09:20:15 +0000 hourly 1 Av: Erik https://www.jenst.se/2008/03/17/wordpress-get-id-by-post-or-page-name/comment-page-1/#comment-13696 Thu, 23 Dec 2010 16:24:20 +0000 http://www.jenst.se/?p=180#comment-13696 Grymt post. Jag har funderat på hur man skulle lösa detta, just nu kör jag med ID, men det kommer bli byte till namn istället :) Åter igen, Tack!

]]>
Av: Philip https://www.jenst.se/2008/03/17/wordpress-get-id-by-post-or-page-name/comment-page-1/#comment-8762 Thu, 12 Aug 2010 13:12:25 +0000 http://www.jenst.se/?p=180#comment-8762 hi and thanks a lot for this post!

i want to use the Extended use 1 code you describe in your post, but i need to call the categories, is it possible to do this?

thanks a lot!!!
Philip

]]>
Av: WordPress hack: Force wp_list_pages() to print current_page_item class | Mark Leong https://www.jenst.se/2008/03/17/wordpress-get-id-by-post-or-page-name/comment-page-1/#comment-8230 Sat, 17 Jul 2010 09:26:24 +0000 http://www.jenst.se/?p=180#comment-8230 […] http://www.jenst.se/2008/03/17/wordpress-get-id-by-post-or-page-name/ on how to query the database by post/page name to get an […]

]]>
Av: Dmitry https://www.jenst.se/2008/03/17/wordpress-get-id-by-post-or-page-name/comment-page-1/#comment-7623 Mon, 28 Jun 2010 14:08:35 +0000 http://www.jenst.se/?p=180#comment-7623 Also you can use WP function ‘get_page_by_path’.
For post:
$p = get_page_by_path(‘my_post_name’,OBJECT,’post’);
echo $p->ID;
For page:
$p = get_page_by_path(‘my_page_name’,OBJECT,’page’);
echo $p->ID;

]]>
Av: Stephen Lang https://www.jenst.se/2008/03/17/wordpress-get-id-by-post-or-page-name/comment-page-1/#comment-6457 Fri, 28 May 2010 10:51:18 +0000 http://www.jenst.se/?p=180#comment-6457 Thank you – just what I needed for a custom wp_list_pages function I’m making :)

]]>
Av: Peter https://www.jenst.se/2008/03/17/wordpress-get-id-by-post-or-page-name/comment-page-1/#comment-236 Fri, 03 Apr 2009 18:22:53 +0000 http://www.jenst.se/?p=180#comment-236 Thanks, this is just what I was looking for – I need to pull a post id from a post slug for something different, and this did the trick.

It’s worth noting that post_name actually holds the slug (generally the post name with dashes inserted for non-alphanumeric characters), and post_title actually holds the title of the post.

]]>