[wp-trac] [WordPress Trac] #23788: get_posts(array('post_type' => 'any')) Should include custom post types in result

WordPress Trac noreply at wordpress.org
Fri Mar 15 15:15:26 UTC 2013


#23788: get_posts(array('post_type' => 'any')) Should include custom post types in
result
-------------------------------+------------------------------
 Reporter:  keendev            |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Post Types         |     Version:  3.5.1
 Severity:  minor              |  Resolution:
 Keywords:  reporter-feedback  |
-------------------------------+------------------------------

Comment (by keendev):

 {{{
 function career_manager() {

         $labels = array(
                 'name'               => _x( 'Careers', 'post type general
 name' ),
                 'singular_name'      => _x( 'Career', 'post type singular
 name' ),
                 'add_new'            => _x( 'Add New', 'brand' ),
                 'add_new_item'       => __( 'Add New Career' ),
                 'edit_item'          => __( 'Edit Career' ),
                 'new_item'           => __( 'New Career' ),
                 'all_items'          => __( 'Career' ),
                 'view_item'          => __( 'View Careers' ),
                 'search_items'       => __( 'Search Careers' ),
                 'not_found'          => __( 'No careers found' ),
                 'not_found_in_trash' => __( 'No careers found in the
 Trash' ),
                 'parent_item_colon'  => '',
                 'menu_name'          => 'Careers'
         );
         $args = array(
                 'labels'                        => $labels,
                 'description'                   => 'Career Manager',
                 'public'                        => true,
                 'show_ui'                       => true,
                 'menu_position'                 => 13,
                 'supports'                      => array( 'title',
 'editor'),
                 'has_archive'                   => true,
                 'register_meta_box_cb'  => 'register_careers_metaboxes'
         );
         register_post_type('career', $args);
 }

 add_action( 'init', 'career_manager' );

 function register_careers_metaboxes() {

         add_meta_box('career_details', 'Details',
 'career_details_meta_box', 'career', 'side');

 }
 }}}


 Referencing:
 {{{
 $expired_posts = get_posts(array(
                         'post_type' => 'any',
                         'meta_query' => array(
                                 'relation' => 'AND',
                                 array(
                                         'key' => '_post_expire_time',
                                         'value' => time(),
                                         'compare' => '<='
                                 ),
                                 array(
                                         'key' => '_post_expire_time',
                                         'value' => '',
                                         'compare' => '!='
                                 )
                         )
                 ));
 }}}

 Some more info: My posts were expired on the 25th feb 2013. It never
 picked up these expired careers. The minute i changed it to post_type =>
 'career', it found the results. Maybe there is something deeper happening
 here?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23788#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list