Make WordPress Core

Changeset 12144


Ignore:
Timestamp:
11/05/2009 04:08:53 PM (17 years ago)
Author:
ryan
Message:

Allow querying multiple post types. Props prettyboymp. fixes #10791

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r12143 r12144  
    14871487                }
    14881488
    1489                 if ( !empty($qv['post_type']) )
    1490                         $qv['post_type'] = sanitize_user($qv['post_type'], true);
     1489                if ( !empty($qv['post_type']) ) {
     1490                        if(is_array($qv['post_type']))
     1491                                $qv['post_type'] = array_map('sanitize_user', $qv['post_type'], array(true));
     1492                        else
     1493                                $qv['post_type'] = sanitize_user($qv['post_type'], true);
     1494                }
    14911495
    14921496                if ( !empty($qv['post_status']) )
    … …  
    20732077                }
    20742078
    2075                 $post_type_cap = $post_type;
     2079                if ( is_array($post_type) )
     2080                        $post_type_cap = 'multiple_post_type';
     2081                else
     2082                        $post_type_cap = $post_type;
    20762083
    20772084                $exclude_post_types = '';
    … …  
    20812088                if ( 'any' == $post_type ) {
    20822089                        $where .= $exclude_post_types;
     2090                } elseif ( !empty( $post_type ) && is_array( $post_type ) ) {
     2091                        $where .= " AND $wpdb->posts.post_type IN ('" . join("', '", $post_type) . "')";
    20832092                } elseif ( ! empty( $post_type ) ) {
    20842093                        $where .= " AND $wpdb->posts.post_type = '$post_type'";
Note: See TracChangeset for help on using the changeset viewer.