[wp-trac] [WordPress Trac] #12727: Allow get_post*() and get_page*() functions to query by more than ID or using an post object.

WordPress Trac wp-trac at lists.automattic.com
Sat Mar 27 06:09:11 UTC 2010


#12727: Allow get_post*() and get_page*() functions to query by more than ID or
using an post object.
--------------------------+-------------------------------------------------
 Reporter:  mikeschinkel  |       Owner:                   
     Type:  enhancement   |      Status:  new              
 Priority:  normal        |   Milestone:  Unassigned       
Component:  Post Types    |     Version:  3.0              
 Severity:  normal        |    Keywords:  posts, post types
--------------------------+-------------------------------------------------
 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.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12727>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list