[wp-hackers] Retrieving post id based on the page title
sudar at sudarmuthu.com
Sat Sep 12 12:10:04 UTC 2009
Thanks for pointing out this function. (I missed it when I looked into
I had a quick look into the function and it is using the following query
SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='page'",
If post revisions is enabled, and there is a auto-save version available
will it not get the id of the revision post row rather than the one which
My gut feeling says that we should also include the condition post_status =
'published'. Am I correct or am I missing something?
(I will do some test to find out whether my theory works!)
On Sat, Sep 12, 2009 at 17:29, Joost de Valk <joost at yoast.com> wrote:
> There's a get_page_by_title, modify it to use with posts, in fact, it
> should probably be modified within core?
> On Sep 12, 2009, at 1:55 PM, Sudar Muthu wrote:
> Hello all,
>> I need to know if there is a built-in function (or recommended way) to
>> retrieve the post id of a page/post based on the post title, without
>> querying the database directly.
>> I know it can be done by querying the database, but I prefer to use the
>> build-in function if available. A quick look into WordPress code, didn't
>> reveal any function.
>> With Regards,
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers