#12727 closed enhancement (duplicate)
Allow get_post*() and get_page*() functions to query by more than ID or using an post object.
Reported by: | mikeschinkel | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description
This is similar to ticket #12726 which I just submitted but is broader. There are many functions in post.php (and probably elsewhere) that accept a $post as a lookup parameter where $post is either an ID or an object with an attribute of "ID" containing a post ID, i.e. $post->ID. It would be nice if they could optionally accept other lookup criteria such as 'path' and 'title.'
It could be something like this:
$post = get_post(new WP_PostBy('path','mypath')); class WP_PostBy { var $field; var $value; function __construct($field,$value) { $this->field = $field; $this->value = $value; } }
Or it could be just as simple as a two element array, i.e.
$post = get_post(array('path','mypath'));
I'll be happy to do the coding if the task is 'blessed' and any special cases that I need to handle are identified.
Change History (7)
#2
in reply to:
↑ 1
@
15 years ago
- Cc mikeschinkel@… added
Replying to nacin:
We have a get_user_by() function. Emulating that for pages/posts/post_types I think is what you're trying to get at with this ticket and #12726. Sounds like a good idea in theory, though strong doubts on 3.0 for it.
Cool. Wasn't really expecting it for 3.0, just wanted to get it into the queue... :-)
We have a get_user_by() function. Emulating that for pages/posts/post_types I think is what you're trying to get at with this ticket and #12726. Sounds like a good idea in theory, though strong doubts on 3.0 for it.