628 * Optional. Array or string of Query parameters. |
631 * Optional. Array or string of Query parameters. |
629 * |
632 * |
630 * @type int $attachment_id Attachment post ID. Used for 'attachment' post_type. |
633 * @type int $attachment_id Attachment post ID. Used for 'attachment' post_type. |
631 * @type int|string $author Author ID, or comma-separated list of IDs. |
634 * @type int|string $author Author ID, or comma-separated list of IDs. |
632 * @type string $author_name User 'user_nicename'. |
635 * @type string $author_name User 'user_nicename'. |
633 * @type array $author__in An array of author IDs to query from. |
636 * @type int[] $author__in An array of author IDs to query from. |
634 * @type array $author__not_in An array of author IDs not to query from. |
637 * @type int[] $author__not_in An array of author IDs not to query from. |
635 * @type bool $cache_results Whether to cache post information. Default true. |
638 * @type bool $cache_results Whether to cache post information. Default true. |
636 * @type int|string $cat Category ID or comma-separated list of IDs (this or any children). |
639 * @type int|string $cat Category ID or comma-separated list of IDs (this or any children). |
637 * @type array $category__and An array of category IDs (AND in). |
640 * @type int[] $category__and An array of category IDs (AND in). |
638 * @type array $category__in An array of category IDs (OR in, no children). |
641 * @type int[] $category__in An array of category IDs (OR in, no children). |
639 * @type array $category__not_in An array of category IDs (NOT in). |
642 * @type int[] $category__not_in An array of category IDs (NOT in). |
640 * @type string $category_name Use category slug (not name, this or any children). |
643 * @type string $category_name Use category slug (not name, this or any children). |
641 * @type array|int $comment_count Filter results by comment count. Provide an integer to match |
644 * @type array|int $comment_count Filter results by comment count. Provide an integer to match |
642 * comment count exactly. Provide an array with integer 'value' |
645 * comment count exactly. Provide an array with integer 'value' |
643 * and 'compare' operator ('=', '!=', '>', '>=', '<', '<=' ) to |
646 * and 'compare' operator ('=', '!=', '>', '>=', '<', '<=' ) to |
644 * compare against comment_count in a specific way. |
647 * compare against comment_count in a specific way. |
694 * @type int $paged The number of the current page. |
697 * @type int $paged The number of the current page. |
695 * @type int $page_id Page ID. |
698 * @type int $page_id Page ID. |
696 * @type string $pagename Page slug. |
699 * @type string $pagename Page slug. |
697 * @type string $perm Show posts if user has the appropriate capability. |
700 * @type string $perm Show posts if user has the appropriate capability. |
698 * @type string $ping_status Ping status. |
701 * @type string $ping_status Ping status. |
699 * @type array $post__in An array of post IDs to retrieve, sticky posts will be included. |
702 * @type int[] $post__in An array of post IDs to retrieve, sticky posts will be included. |
700 * @type array $post__not_in An array of post IDs not to retrieve. Note: a string of comma- |
703 * @type int[] $post__not_in An array of post IDs not to retrieve. Note: a string of comma- |
701 * separated IDs will NOT work. |
704 * separated IDs will NOT work. |
702 * @type string $post_mime_type The mime type of the post. Used for 'attachment' post_type. |
705 * @type string $post_mime_type The mime type of the post. Used for 'attachment' post_type. |
703 * @type array $post_name__in An array of post slugs that results must match. |
706 * @type string[] $post_name__in An array of post slugs that results must match. |
704 * @type int $post_parent Page ID to retrieve child pages for. Use 0 to only retrieve |
707 * @type int $post_parent Page ID to retrieve child pages for. Use 0 to only retrieve |
705 * top-level pages. |
708 * top-level pages. |
706 * @type array $post_parent__in An array containing parent page IDs to query child pages from. |
709 * @type int[] $post_parent__in An array containing parent page IDs to query child pages from. |
707 * @type array $post_parent__not_in An array containing parent page IDs not to query child pages from. |
710 * @type int[] $post_parent__not_in An array containing parent page IDs not to query child pages from. |
708 * @type string|array $post_type A post type slug (string) or array of post type slugs. |
711 * @type string|array $post_type A post type slug (string) or array of post type slugs. |
709 * Default 'any' if using 'tax_query'. |
712 * Default 'any' if using 'tax_query'. |
710 * @type string|array $post_status A post status (string) or array of post statuses. |
713 * @type string|array $post_status A post status (string) or array of post statuses. |
711 * @type int $posts_per_page The number of posts to query for. Use -1 to request all posts. |
714 * @type int $posts_per_page The number of posts to query for. Use -1 to request all posts. |
712 * @type int $posts_per_archive_page The number of posts to query for by archive page. Overrides |
715 * @type int $posts_per_archive_page The number of posts to query for by archive page. Overrides |
718 * the 'wp_query_search_exclusion_prefix' filter. |
721 * the 'wp_query_search_exclusion_prefix' filter. |
719 * @type int $second Second of the minute. Default empty. Accepts numbers 0-60. |
722 * @type int $second Second of the minute. Default empty. Accepts numbers 0-60. |
720 * @type bool $sentence Whether to search by phrase. Default false. |
723 * @type bool $sentence Whether to search by phrase. Default false. |
721 * @type bool $suppress_filters Whether to suppress filters. Default false. |
724 * @type bool $suppress_filters Whether to suppress filters. Default false. |
722 * @type string $tag Tag slug. Comma-separated (either), Plus-separated (all). |
725 * @type string $tag Tag slug. Comma-separated (either), Plus-separated (all). |
723 * @type array $tag__and An array of tag IDs (AND in). |
726 * @type int[] $tag__and An array of tag IDs (AND in). |
724 * @type array $tag__in An array of tag IDs (OR in). |
727 * @type int[] $tag__in An array of tag IDs (OR in). |
725 * @type array $tag__not_in An array of tag IDs (NOT in). |
728 * @type int[] $tag__not_in An array of tag IDs (NOT in). |
726 * @type int $tag_id Tag id or comma-separated list of IDs. |
729 * @type int $tag_id Tag id or comma-separated list of IDs. |
727 * @type array $tag_slug__and An array of tag slugs (AND in). |
730 * @type string[] $tag_slug__and An array of tag slugs (AND in). |
728 * @type array $tag_slug__in An array of tag slugs (OR in). unless 'ignore_sticky_posts' is |
731 * @type string[] $tag_slug__in An array of tag slugs (OR in). unless 'ignore_sticky_posts' is |
729 * true. Note: a string of comma-separated IDs will NOT work. |
732 * true. Note: a string of comma-separated IDs will NOT work. |
730 * @type array $tax_query An associative array of WP_Tax_Query arguments. |
733 * @type array $tax_query An associative array of WP_Tax_Query arguments. |
731 * See WP_Tax_Query->queries. |
734 * See WP_Tax_Query->__construct(). |
732 * @type string $title Post title. |
735 * @type string $title Post title. |
733 * @type bool $update_post_meta_cache Whether to update the post meta cache. Default true. |
736 * @type bool $update_post_meta_cache Whether to update the post meta cache. Default true. |
734 * @type bool $update_post_term_cache Whether to update the post term cache. Default true. |
737 * @type bool $update_post_term_cache Whether to update the post term cache. Default true. |
735 * @type bool $lazy_load_term_meta Whether to lazy-load term meta. Setting to false will |
738 * @type bool $lazy_load_term_meta Whether to lazy-load term meta. Setting to false will |
736 * disable cache priming for term meta, so that each |
739 * disable cache priming for term meta, so that each |
757 $this->is_robots = true; |
760 $this->is_robots = true; |
758 } elseif ( ! empty( $qv['favicon'] ) ) { |
761 } elseif ( ! empty( $qv['favicon'] ) ) { |
759 $this->is_favicon = true; |
762 $this->is_favicon = true; |
760 } |
763 } |
761 |
764 |
762 if ( ! is_scalar( $qv['p'] ) || $qv['p'] < 0 ) { |
765 if ( ! is_scalar( $qv['p'] ) || (int) $qv['p'] < 0 ) { |
763 $qv['p'] = 0; |
766 $qv['p'] = 0; |
764 $qv['error'] = '404'; |
767 $qv['error'] = '404'; |
765 } else { |
768 } else { |
766 $qv['p'] = intval( $qv['p'] ); |
769 $qv['p'] = (int) $qv['p']; |
767 } |
770 } |
768 |
771 |
769 $qv['page_id'] = absint( $qv['page_id'] ); |
772 $qv['page_id'] = absint( $qv['page_id'] ); |
770 $qv['year'] = absint( $qv['year'] ); |
773 $qv['year'] = absint( $qv['year'] ); |
771 $qv['monthnum'] = absint( $qv['monthnum'] ); |
774 $qv['monthnum'] = absint( $qv['monthnum'] ); |
1602 } |
1605 } |
1603 |
1606 |
1604 // If RAND() contains a seed value, sanitize and add to allowed keys. |
1607 // If RAND() contains a seed value, sanitize and add to allowed keys. |
1605 $rand_with_seed = false; |
1608 $rand_with_seed = false; |
1606 if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) { |
1609 if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) { |
1607 $orderby = sprintf( 'RAND(%s)', intval( $matches[1] ) ); |
1610 $orderby = sprintf( 'RAND(%s)', (int) $matches[1] ); |
1608 $allowed_keys[] = $orderby; |
1611 $allowed_keys[] = $orderby; |
1609 $rand_with_seed = true; |
1612 $rand_with_seed = true; |
1610 } |
1613 } |
1611 |
1614 |
1612 if ( ! in_array( $orderby, $allowed_keys, true ) ) { |
1615 if ( ! in_array( $orderby, $allowed_keys, true ) ) { |
1713 /** |
1716 /** |
1714 * Fires after a 404 is triggered. |
1717 * Fires after a 404 is triggered. |
1715 * |
1718 * |
1716 * @since 5.5.0 |
1719 * @since 5.5.0 |
1717 * |
1720 * |
1718 * @param WP_Query $this The WP_Query instance (passed by reference). |
1721 * @param WP_Query $query The WP_Query instance (passed by reference). |
1719 */ |
1722 */ |
1720 do_action_ref_array( 'set_404', array( $this ) ); |
1723 do_action_ref_array( 'set_404', array( $this ) ); |
1721 } |
1724 } |
1722 |
1725 |
1723 /** |
1726 /** |
1724 * Retrieve query variable. |
1727 * Retrieves the value of a query variable. |
1725 * |
1728 * |
1726 * @since 1.5.0 |
1729 * @since 1.5.0 |
1727 * @since 3.9.0 The `$default` argument was introduced. |
1730 * @since 3.9.0 The `$default` argument was introduced. |
1728 * |
1731 * |
1729 * @param string $query_var Query variable key. |
1732 * @param string $query_var Query variable key. |
1730 * @param mixed $default Optional. Value to return if the query variable is not set. Default empty. |
1733 * @param mixed $default Optional. Value to return if the query variable is not set. Default empty string. |
1731 * @return mixed Contents of the query variable. |
1734 * @return mixed Contents of the query variable. |
1732 */ |
1735 */ |
1733 public function get( $query_var, $default = '' ) { |
1736 public function get( $query_var, $default = '' ) { |
1734 if ( isset( $this->query_vars[ $query_var ] ) ) { |
1737 if ( isset( $this->query_vars[ $query_var ] ) ) { |
1735 return $this->query_vars[ $query_var ]; |
1738 return $this->query_vars[ $query_var ]; |
2261 // Matching by comment count. |
2266 // Matching by comment count. |
2262 if ( isset( $q['comment_count'] ) ) { |
2267 if ( isset( $q['comment_count'] ) ) { |
2263 // Numeric comment count is converted to array format. |
2268 // Numeric comment count is converted to array format. |
2264 if ( is_numeric( $q['comment_count'] ) ) { |
2269 if ( is_numeric( $q['comment_count'] ) ) { |
2265 $q['comment_count'] = array( |
2270 $q['comment_count'] = array( |
2266 'value' => intval( $q['comment_count'] ), |
2271 'value' => (int) $q['comment_count'], |
2267 ); |
2272 ); |
2268 } |
2273 } |
2269 |
2274 |
2270 if ( isset( $q['comment_count']['value'] ) ) { |
2275 if ( isset( $q['comment_count']['value'] ) ) { |
2271 $q['comment_count'] = array_merge( |
2276 $q['comment_count'] = array_merge( |
2418 if ( 'any' === $post_type ) { |
2423 if ( 'any' === $post_type ) { |
2419 $in_search_post_types = get_post_types( array( 'exclude_from_search' => false ) ); |
2424 $in_search_post_types = get_post_types( array( 'exclude_from_search' => false ) ); |
2420 if ( empty( $in_search_post_types ) ) { |
2425 if ( empty( $in_search_post_types ) ) { |
2421 $where .= ' AND 1=0 '; |
2426 $where .= ' AND 1=0 '; |
2422 } else { |
2427 } else { |
2423 $where .= " AND {$wpdb->posts}.post_type IN ('" . join( "', '", array_map( 'esc_sql', $in_search_post_types ) ) . "')"; |
2428 $where .= " AND {$wpdb->posts}.post_type IN ('" . implode( "', '", array_map( 'esc_sql', $in_search_post_types ) ) . "')"; |
2424 } |
2429 } |
2425 } elseif ( ! empty( $post_type ) && is_array( $post_type ) ) { |
2430 } elseif ( ! empty( $post_type ) && is_array( $post_type ) ) { |
2426 $where .= " AND {$wpdb->posts}.post_type IN ('" . join( "', '", esc_sql( $post_type ) ) . "')"; |
2431 $where .= " AND {$wpdb->posts}.post_type IN ('" . implode( "', '", esc_sql( $post_type ) ) . "')"; |
2427 } elseif ( ! empty( $post_type ) ) { |
2432 } elseif ( ! empty( $post_type ) ) { |
2428 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_type = %s", $post_type ); |
2433 $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_type = %s", $post_type ); |
2429 $post_type_object = get_post_type_object( $post_type ); |
2434 $post_type_object = get_post_type_object( $post_type ); |
2430 } elseif ( $this->is_attachment ) { |
2435 } elseif ( $this->is_attachment ) { |
2431 $where .= " AND {$wpdb->posts}.post_type = 'attachment'"; |
2436 $where .= " AND {$wpdb->posts}.post_type = 'attachment'"; |
2483 $r_status = array_merge( $r_status, $p_status ); |
2488 $r_status = array_merge( $r_status, $p_status ); |
2484 unset( $p_status ); |
2489 unset( $p_status ); |
2485 } |
2490 } |
2486 |
2491 |
2487 if ( ! empty( $e_status ) ) { |
2492 if ( ! empty( $e_status ) ) { |
2488 $statuswheres[] = '(' . join( ' AND ', $e_status ) . ')'; |
2493 $statuswheres[] = '(' . implode( ' AND ', $e_status ) . ')'; |
2489 } |
2494 } |
2490 if ( ! empty( $r_status ) ) { |
2495 if ( ! empty( $r_status ) ) { |
2491 if ( ! empty( $q['perm'] ) && 'editable' === $q['perm'] && ! current_user_can( $edit_others_cap ) ) { |
2496 if ( ! empty( $q['perm'] ) && 'editable' === $q['perm'] && ! current_user_can( $edit_others_cap ) ) { |
2492 $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . join( ' OR ', $r_status ) . '))'; |
2497 $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . implode( ' OR ', $r_status ) . '))'; |
2493 } else { |
2498 } else { |
2494 $statuswheres[] = '(' . join( ' OR ', $r_status ) . ')'; |
2499 $statuswheres[] = '(' . implode( ' OR ', $r_status ) . ')'; |
2495 } |
2500 } |
2496 } |
2501 } |
2497 if ( ! empty( $p_status ) ) { |
2502 if ( ! empty( $p_status ) ) { |
2498 if ( ! empty( $q['perm'] ) && 'readable' === $q['perm'] && ! current_user_can( $read_private_cap ) ) { |
2503 if ( ! empty( $q['perm'] ) && 'readable' === $q['perm'] && ! current_user_can( $read_private_cap ) ) { |
2499 $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . join( ' OR ', $p_status ) . '))'; |
2504 $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . implode( ' OR ', $p_status ) . '))'; |
2500 } else { |
2505 } else { |
2501 $statuswheres[] = '(' . join( ' OR ', $p_status ) . ')'; |
2506 $statuswheres[] = '(' . implode( ' OR ', $p_status ) . ')'; |
2502 } |
2507 } |
2503 } |
2508 } |
2504 if ( $post_status_join ) { |
2509 if ( $post_status_join ) { |
2505 $join .= " LEFT JOIN {$wpdb->posts} AS p2 ON ({$wpdb->posts}.post_parent = p2.ID) "; |
2510 $join .= " LEFT JOIN {$wpdb->posts} AS p2 ON ({$wpdb->posts}.post_parent = p2.ID) "; |
2506 foreach ( $statuswheres as $index => $statuswhere ) { |
2511 foreach ( $statuswheres as $index => $statuswhere ) { |
2556 * Filters the WHERE clause of the query. |
2561 * Filters the WHERE clause of the query. |
2557 * |
2562 * |
2558 * @since 1.5.0 |
2563 * @since 1.5.0 |
2559 * |
2564 * |
2560 * @param string $where The WHERE clause of the query. |
2565 * @param string $where The WHERE clause of the query. |
2561 * @param WP_Query $this The WP_Query instance (passed by reference). |
2566 * @param WP_Query $query The WP_Query instance (passed by reference). |
2562 */ |
2567 */ |
2563 $where = apply_filters_ref_array( 'posts_where', array( $where, &$this ) ); |
2568 $where = apply_filters_ref_array( 'posts_where', array( $where, &$this ) ); |
2564 |
2569 |
2565 /** |
2570 /** |
2566 * Filters the JOIN clause of the query. |
2571 * Filters the JOIN clause of the query. |
2567 * |
2572 * |
2568 * @since 1.5.0 |
2573 * @since 1.5.0 |
2569 * |
2574 * |
2570 * @param string $join The JOIN clause of the query. |
2575 * @param string $join The JOIN clause of the query. |
2571 * @param WP_Query $this The WP_Query instance (passed by reference). |
2576 * @param WP_Query $query The WP_Query instance (passed by reference). |
2572 */ |
2577 */ |
2573 $join = apply_filters_ref_array( 'posts_join', array( $join, &$this ) ); |
2578 $join = apply_filters_ref_array( 'posts_join', array( $join, &$this ) ); |
2574 } |
2579 } |
2575 |
2580 |
2576 // Paging. |
2581 // Paging. |
2591 } |
2596 } |
2592 |
2597 |
2593 // Comments feeds. |
2598 // Comments feeds. |
2594 if ( $this->is_comment_feed && ! $this->is_singular ) { |
2599 if ( $this->is_comment_feed && ! $this->is_singular ) { |
2595 if ( $this->is_archive || $this->is_search ) { |
2600 if ( $this->is_archive || $this->is_search ) { |
2596 $cjoin = "JOIN {$wpdb->posts} ON ({$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID) $join "; |
2601 $cjoin = "JOIN {$wpdb->posts} ON ( {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID ) $join "; |
2597 $cwhere = "WHERE comment_approved = '1' $where"; |
2602 $cwhere = "WHERE comment_approved = '1' $where"; |
2598 $cgroupby = "{$wpdb->comments}.comment_id"; |
2603 $cgroupby = "{$wpdb->comments}.comment_id"; |
2599 } else { // Other non-singular, e.g. front. |
2604 } else { // Other non-singular, e.g. front. |
2600 $cjoin = "JOIN {$wpdb->posts} ON ( {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID )"; |
2605 $cjoin = "JOIN {$wpdb->posts} ON ( {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID )"; |
2601 $cwhere = "WHERE ( post_status = 'publish' OR ( post_status = 'inherit' AND post_type = 'attachment' ) ) AND comment_approved = '1'"; |
2606 $cwhere = "WHERE ( post_status = 'publish' OR ( post_status = 'inherit' AND post_type = 'attachment' ) ) AND comment_approved = '1'"; |
2607 * Filters the JOIN clause of the comments feed query before sending. |
2612 * Filters the JOIN clause of the comments feed query before sending. |
2608 * |
2613 * |
2609 * @since 2.2.0 |
2614 * @since 2.2.0 |
2610 * |
2615 * |
2611 * @param string $cjoin The JOIN clause of the query. |
2616 * @param string $cjoin The JOIN clause of the query. |
2612 * @param WP_Query $this The WP_Query instance (passed by reference). |
2617 * @param WP_Query $query The WP_Query instance (passed by reference). |
2613 */ |
2618 */ |
2614 $cjoin = apply_filters_ref_array( 'comment_feed_join', array( $cjoin, &$this ) ); |
2619 $cjoin = apply_filters_ref_array( 'comment_feed_join', array( $cjoin, &$this ) ); |
2615 |
2620 |
2616 /** |
2621 /** |
2617 * Filters the WHERE clause of the comments feed query before sending. |
2622 * Filters the WHERE clause of the comments feed query before sending. |
2618 * |
2623 * |
2619 * @since 2.2.0 |
2624 * @since 2.2.0 |
2620 * |
2625 * |
2621 * @param string $cwhere The WHERE clause of the query. |
2626 * @param string $cwhere The WHERE clause of the query. |
2622 * @param WP_Query $this The WP_Query instance (passed by reference). |
2627 * @param WP_Query $query The WP_Query instance (passed by reference). |
2623 */ |
2628 */ |
2624 $cwhere = apply_filters_ref_array( 'comment_feed_where', array( $cwhere, &$this ) ); |
2629 $cwhere = apply_filters_ref_array( 'comment_feed_where', array( $cwhere, &$this ) ); |
2625 |
2630 |
2626 /** |
2631 /** |
2627 * Filters the GROUP BY clause of the comments feed query before sending. |
2632 * Filters the GROUP BY clause of the comments feed query before sending. |
2628 * |
2633 * |
2629 * @since 2.2.0 |
2634 * @since 2.2.0 |
2630 * |
2635 * |
2631 * @param string $cgroupby The GROUP BY clause of the query. |
2636 * @param string $cgroupby The GROUP BY clause of the query. |
2632 * @param WP_Query $this The WP_Query instance (passed by reference). |
2637 * @param WP_Query $query The WP_Query instance (passed by reference). |
2633 */ |
2638 */ |
2634 $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( $cgroupby, &$this ) ); |
2639 $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( $cgroupby, &$this ) ); |
2635 |
2640 |
2636 /** |
2641 /** |
2637 * Filters the ORDER BY clause of the comments feed query before sending. |
2642 * Filters the ORDER BY clause of the comments feed query before sending. |
2638 * |
2643 * |
2639 * @since 2.8.0 |
2644 * @since 2.8.0 |
2640 * |
2645 * |
2641 * @param string $corderby The ORDER BY clause of the query. |
2646 * @param string $corderby The ORDER BY clause of the query. |
2642 * @param WP_Query $this The WP_Query instance (passed by reference). |
2647 * @param WP_Query $query The WP_Query instance (passed by reference). |
2643 */ |
2648 */ |
2644 $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) ); |
2649 $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) ); |
2645 |
2650 |
2646 /** |
2651 /** |
2647 * Filters the LIMIT clause of the comments feed query before sending. |
2652 * Filters the LIMIT clause of the comments feed query before sending. |
2648 * |
2653 * |
2649 * @since 2.8.0 |
2654 * @since 2.8.0 |
2650 * |
2655 * |
2651 * @param string $climits The JOIN clause of the query. |
2656 * @param string $climits The JOIN clause of the query. |
2652 * @param WP_Query $this The WP_Query instance (passed by reference). |
2657 * @param WP_Query $query The WP_Query instance (passed by reference). |
2653 */ |
2658 */ |
2654 $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) ); |
2659 $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) ); |
2655 } |
2660 } |
2656 |
2661 |
2657 $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; |
2662 $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; |
2658 $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; |
2663 $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; |
2659 $climits = ( ! empty( $climits ) ) ? $climits : ''; |
2664 $climits = ( ! empty( $climits ) ) ? $climits : ''; |
2660 |
2665 |
2661 $comments = (array) $wpdb->get_results( "SELECT $distinct {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits" ); |
2666 $comments = (array) $wpdb->get_results( "SELECT $distinct {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits" ); |
2662 // Convert to WP_Comment. |
2667 // Convert to WP_Comment. |
|
2668 /** @var WP_Comment[] */ |
2663 $this->comments = array_map( 'get_comment', $comments ); |
2669 $this->comments = array_map( 'get_comment', $comments ); |
2664 $this->comment_count = count( $this->comments ); |
2670 $this->comment_count = count( $this->comments ); |
2665 |
2671 |
2666 $post_ids = array(); |
2672 $post_ids = array(); |
2667 |
2673 |
2668 foreach ( $this->comments as $comment ) { |
2674 foreach ( $this->comments as $comment ) { |
2669 $post_ids[] = (int) $comment->comment_post_ID; |
2675 $post_ids[] = (int) $comment->comment_post_ID; |
2670 } |
2676 } |
2671 |
2677 |
2672 $post_ids = join( ',', $post_ids ); |
2678 $post_ids = implode( ',', $post_ids ); |
2673 $join = ''; |
2679 $join = ''; |
2674 if ( $post_ids ) { |
2680 if ( $post_ids ) { |
2675 $where = "AND {$wpdb->posts}.ID IN ($post_ids) "; |
2681 $where = "AND {$wpdb->posts}.ID IN ($post_ids) "; |
2676 } else { |
2682 } else { |
2677 $where = 'AND 0'; |
2683 $where = 'AND 0'; |
2691 * Specifically for manipulating paging queries. |
2697 * Specifically for manipulating paging queries. |
2692 * |
2698 * |
2693 * @since 1.5.0 |
2699 * @since 1.5.0 |
2694 * |
2700 * |
2695 * @param string $where The WHERE clause of the query. |
2701 * @param string $where The WHERE clause of the query. |
2696 * @param WP_Query $this The WP_Query instance (passed by reference). |
2702 * @param WP_Query $query The WP_Query instance (passed by reference). |
2697 */ |
2703 */ |
2698 $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); |
2704 $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); |
2699 |
2705 |
2700 /** |
2706 /** |
2701 * Filters the GROUP BY clause of the query. |
2707 * Filters the GROUP BY clause of the query. |
2702 * |
2708 * |
2703 * @since 2.0.0 |
2709 * @since 2.0.0 |
2704 * |
2710 * |
2705 * @param string $groupby The GROUP BY clause of the query. |
2711 * @param string $groupby The GROUP BY clause of the query. |
2706 * @param WP_Query $this The WP_Query instance (passed by reference). |
2712 * @param WP_Query $query The WP_Query instance (passed by reference). |
2707 */ |
2713 */ |
2708 $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); |
2714 $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); |
2709 |
2715 |
2710 /** |
2716 /** |
2711 * Filters the JOIN clause of the query. |
2717 * Filters the JOIN clause of the query. |
2713 * Specifically for manipulating paging queries. |
2719 * Specifically for manipulating paging queries. |
2714 * |
2720 * |
2715 * @since 1.5.0 |
2721 * @since 1.5.0 |
2716 * |
2722 * |
2717 * @param string $join The JOIN clause of the query. |
2723 * @param string $join The JOIN clause of the query. |
2718 * @param WP_Query $this The WP_Query instance (passed by reference). |
2724 * @param WP_Query $query The WP_Query instance (passed by reference). |
2719 */ |
2725 */ |
2720 $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); |
2726 $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); |
2721 |
2727 |
2722 /** |
2728 /** |
2723 * Filters the ORDER BY clause of the query. |
2729 * Filters the ORDER BY clause of the query. |
2724 * |
2730 * |
2725 * @since 1.5.1 |
2731 * @since 1.5.1 |
2726 * |
2732 * |
2727 * @param string $orderby The ORDER BY clause of the query. |
2733 * @param string $orderby The ORDER BY clause of the query. |
2728 * @param WP_Query $this The WP_Query instance (passed by reference). |
2734 * @param WP_Query $query The WP_Query instance (passed by reference). |
2729 */ |
2735 */ |
2730 $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); |
2736 $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); |
2731 |
2737 |
2732 /** |
2738 /** |
2733 * Filters the DISTINCT clause of the query. |
2739 * Filters the DISTINCT clause of the query. |
2734 * |
2740 * |
2735 * @since 2.1.0 |
2741 * @since 2.1.0 |
2736 * |
2742 * |
2737 * @param string $distinct The DISTINCT clause of the query. |
2743 * @param string $distinct The DISTINCT clause of the query. |
2738 * @param WP_Query $this The WP_Query instance (passed by reference). |
2744 * @param WP_Query $query The WP_Query instance (passed by reference). |
2739 */ |
2745 */ |
2740 $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) ); |
2746 $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) ); |
2741 |
2747 |
2742 /** |
2748 /** |
2743 * Filters the LIMIT clause of the query. |
2749 * Filters the LIMIT clause of the query. |
2744 * |
2750 * |
2745 * @since 2.1.0 |
2751 * @since 2.1.0 |
2746 * |
2752 * |
2747 * @param string $limits The LIMIT clause of the query. |
2753 * @param string $limits The LIMIT clause of the query. |
2748 * @param WP_Query $this The WP_Query instance (passed by reference). |
2754 * @param WP_Query $query The WP_Query instance (passed by reference). |
2749 */ |
2755 */ |
2750 $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); |
2756 $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); |
2751 |
2757 |
2752 /** |
2758 /** |
2753 * Filters the SELECT clause of the query. |
2759 * Filters the SELECT clause of the query. |
2754 * |
2760 * |
2755 * @since 2.1.0 |
2761 * @since 2.1.0 |
2756 * |
2762 * |
2757 * @param string $fields The SELECT clause of the query. |
2763 * @param string $fields The SELECT clause of the query. |
2758 * @param WP_Query $this The WP_Query instance (passed by reference). |
2764 * @param WP_Query $query The WP_Query instance (passed by reference). |
2759 */ |
2765 */ |
2760 $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); |
2766 $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); |
2761 |
2767 |
2762 /** |
2768 /** |
2763 * Filters all query clauses at once, for convenience. |
2769 * Filters all query clauses at once, for convenience. |
2925 * Filters the completed SQL query before sending. |
2931 * Filters the completed SQL query before sending. |
2926 * |
2932 * |
2927 * @since 2.0.0 |
2933 * @since 2.0.0 |
2928 * |
2934 * |
2929 * @param string $request The complete SQL query. |
2935 * @param string $request The complete SQL query. |
2930 * @param WP_Query $this The WP_Query instance (passed by reference). |
2936 * @param WP_Query $query The WP_Query instance (passed by reference). |
2931 */ |
2937 */ |
2932 $this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) ); |
2938 $this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) ); |
2933 } |
2939 } |
2934 |
2940 |
2935 /** |
2941 /** |
2936 * Filters the posts array before the query takes place. |
2942 * Filters the posts array before the query takes place. |
2937 * |
2943 * |
2938 * Return a non-null value to bypass WordPress's default post queries. |
2944 * Return a non-null value to bypass WordPress' default post queries. |
2939 * |
2945 * |
2940 * Filtering functions that require pagination information are encouraged to set |
2946 * Filtering functions that require pagination information are encouraged to set |
2941 * the `found_posts` and `max_num_pages` properties of the WP_Query object, |
2947 * the `found_posts` and `max_num_pages` properties of the WP_Query object, |
2942 * passed to the filter by reference. If WP_Query does not perform a database |
2948 * passed to the filter by reference. If WP_Query does not perform a database |
2943 * query, it will not have enough information to generate these values itself. |
2949 * query, it will not have enough information to generate these values itself. |
2944 * |
2950 * |
2945 * @since 4.6.0 |
2951 * @since 4.6.0 |
2946 * |
2952 * |
2947 * @param array|null $posts Return an array of post data to short-circuit WP's query, |
2953 * @param WP_Post[]|int[]|null $posts Return an array of post data to short-circuit WP's query, |
2948 * or null to allow WP to run its normal queries. |
2954 * or null to allow WP to run its normal queries. |
2949 * @param WP_Query $this The WP_Query instance (passed by reference). |
2955 * @param WP_Query $query The WP_Query instance (passed by reference). |
2950 */ |
2956 */ |
2951 $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) ); |
2957 $this->posts = apply_filters_ref_array( 'posts_pre_query', array( null, &$this ) ); |
2952 |
2958 |
2953 if ( 'ids' === $q['fields'] ) { |
2959 if ( 'ids' === $q['fields'] ) { |
2954 if ( null === $this->posts ) { |
2960 if ( null === $this->posts ) { |
2955 $this->posts = $wpdb->get_col( $this->request ); |
2961 $this->posts = $wpdb->get_col( $this->request ); |
2956 } |
2962 } |
2957 |
2963 |
|
2964 /** @var int[] */ |
2958 $this->posts = array_map( 'intval', $this->posts ); |
2965 $this->posts = array_map( 'intval', $this->posts ); |
2959 $this->post_count = count( $this->posts ); |
2966 $this->post_count = count( $this->posts ); |
2960 $this->set_found_posts( $q, $limits ); |
2967 $this->set_found_posts( $q, $limits ); |
2961 |
2968 |
2962 return $this->posts; |
2969 return $this->posts; |
3028 } |
3036 } |
3029 } |
3037 } |
3030 |
3038 |
3031 // Convert to WP_Post objects. |
3039 // Convert to WP_Post objects. |
3032 if ( $this->posts ) { |
3040 if ( $this->posts ) { |
|
3041 /** @var WP_Post[] */ |
3033 $this->posts = array_map( 'get_post', $this->posts ); |
3042 $this->posts = array_map( 'get_post', $this->posts ); |
3034 } |
3043 } |
3035 |
3044 |
3036 if ( ! $q['suppress_filters'] ) { |
3045 if ( ! $q['suppress_filters'] ) { |
3037 /** |
3046 /** |
3038 * Filters the raw post results array, prior to status checks. |
3047 * Filters the raw post results array, prior to status checks. |
3039 * |
3048 * |
3040 * @since 2.3.0 |
3049 * @since 2.3.0 |
3041 * |
3050 * |
3042 * @param WP_Post[] $posts Array of post objects. |
3051 * @param WP_Post[] $posts Array of post objects. |
3043 * @param WP_Query $this The WP_Query instance (passed by reference). |
3052 * @param WP_Query $query The WP_Query instance (passed by reference). |
3044 */ |
3053 */ |
3045 $this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) ); |
3054 $this->posts = apply_filters_ref_array( 'posts_results', array( $this->posts, &$this ) ); |
3046 } |
3055 } |
3047 |
3056 |
3048 if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) { |
3057 if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) { |
3064 $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) ); |
3073 $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) ); |
3065 |
3074 |
3066 $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits"; |
3075 $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits"; |
3067 $comments = $wpdb->get_results( $comments_request ); |
3076 $comments = $wpdb->get_results( $comments_request ); |
3068 // Convert to WP_Comment. |
3077 // Convert to WP_Comment. |
|
3078 /** @var WP_Comment[] */ |
3069 $this->comments = array_map( 'get_comment', $comments ); |
3079 $this->comments = array_map( 'get_comment', $comments ); |
3070 $this->comment_count = count( $this->comments ); |
3080 $this->comment_count = count( $this->comments ); |
3071 } |
3081 } |
3072 |
3082 |
3073 // Check post status to determine if post should be displayed. |
3083 // Check post status to determine if post should be displayed. |
3183 * internally processed. |
3193 * internally processed. |
3184 * |
3194 * |
3185 * @since 1.5.0 |
3195 * @since 1.5.0 |
3186 * |
3196 * |
3187 * @param WP_Post[] $posts Array of post objects. |
3197 * @param WP_Post[] $posts Array of post objects. |
3188 * @param WP_Query $this The WP_Query instance (passed by reference). |
3198 * @param WP_Query $query The WP_Query instance (passed by reference). |
3189 */ |
3199 */ |
3190 $this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) ); |
3200 $this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) ); |
3191 } |
3201 } |
3192 |
3202 |
3193 // Ensure that any posts added/modified via one of the filters above are |
3203 // Ensure that any posts added/modified via one of the filters above are |
3194 // of the type WP_Post and are filtered. |
3204 // of the type WP_Post and are filtered. |
3195 if ( $this->posts ) { |
3205 if ( $this->posts ) { |
3196 $this->post_count = count( $this->posts ); |
3206 $this->post_count = count( $this->posts ); |
3197 |
3207 |
|
3208 /** @var WP_Post[] */ |
3198 $this->posts = array_map( 'get_post', $this->posts ); |
3209 $this->posts = array_map( 'get_post', $this->posts ); |
3199 |
3210 |
3200 if ( $q['cache_results'] ) { |
3211 if ( $q['cache_results'] ) { |
3201 update_post_caches( $this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); |
3212 update_post_caches( $this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache'] ); |
3202 } |
3213 } |
3203 |
3214 |
|
3215 /** @var WP_Post */ |
3204 $this->post = reset( $this->posts ); |
3216 $this->post = reset( $this->posts ); |
3205 } else { |
3217 } else { |
3206 $this->post_count = 0; |
3218 $this->post_count = 0; |
3207 $this->posts = array(); |
3219 $this->posts = array(); |
3208 } |
3220 } |
3218 * Set up the amount of found posts and the number of pages (if limit clause was used) |
3230 * Set up the amount of found posts and the number of pages (if limit clause was used) |
3219 * for the current query. |
3231 * for the current query. |
3220 * |
3232 * |
3221 * @since 3.5.0 |
3233 * @since 3.5.0 |
3222 * |
3234 * |
|
3235 * @global wpdb $wpdb WordPress database abstraction object. |
|
3236 * |
3223 * @param array $q Query variables. |
3237 * @param array $q Query variables. |
3224 * @param string $limits LIMIT clauses of the query. |
3238 * @param string $limits LIMIT clauses of the query. |
3225 */ |
3239 */ |
3226 private function set_found_posts( $q, $limits ) { |
3240 private function set_found_posts( $q, $limits ) { |
3227 global $wpdb; |
3241 global $wpdb; |
|
3242 |
3228 // Bail if posts is an empty array. Continue if posts is an empty string, |
3243 // Bail if posts is an empty array. Continue if posts is an empty string, |
3229 // null, or false to accommodate caching plugins that fill posts later. |
3244 // null, or false to accommodate caching plugins that fill posts later. |
3230 if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) ) { |
3245 if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) ) { |
3231 return; |
3246 return; |
3232 } |
3247 } |
3330 /** |
3346 /** |
3331 * Fires once the loop has ended. |
3347 * Fires once the loop has ended. |
3332 * |
3348 * |
3333 * @since 2.0.0 |
3349 * @since 2.0.0 |
3334 * |
3350 * |
3335 * @param WP_Query $this The WP_Query instance (passed by reference). |
3351 * @param WP_Query $query The WP_Query instance (passed by reference). |
3336 */ |
3352 */ |
3337 do_action_ref_array( 'loop_end', array( &$this ) ); |
3353 do_action_ref_array( 'loop_end', array( &$this ) ); |
3338 // Do some cleaning up after the loop. |
3354 // Do some cleaning up after the loop. |
3339 $this->rewind_posts(); |
3355 $this->rewind_posts(); |
3340 } elseif ( 0 === $this->post_count ) { |
3356 } elseif ( 0 === $this->post_count ) { |
3341 /** |
3357 /** |
3342 * Fires if no results are found in a post query. |
3358 * Fires if no results are found in a post query. |
3343 * |
3359 * |
3344 * @since 4.9.0 |
3360 * @since 4.9.0 |
3345 * |
3361 * |
3346 * @param WP_Query $this The WP_Query instance. |
3362 * @param WP_Query $query The WP_Query instance. |
3347 */ |
3363 */ |
3348 do_action( 'loop_no_results', $this ); |
3364 do_action( 'loop_no_results', $this ); |
3349 } |
3365 } |
3350 |
3366 |
3351 $this->in_the_loop = false; |
3367 $this->in_the_loop = false; |
3447 $this->query_vars = $this->query; |
3464 $this->query_vars = $this->query; |
3448 return $this->get_posts(); |
3465 return $this->get_posts(); |
3449 } |
3466 } |
3450 |
3467 |
3451 /** |
3468 /** |
3452 * Retrieve queried object. |
3469 * Retrieves the currently queried object. |
3453 * |
3470 * |
3454 * If queried object is not set, then the queried object will be set from |
3471 * If queried object is not set, then the queried object will be set from |
3455 * the category, tag, taxonomy, posts page, single post, page, or author |
3472 * the category, tag, taxonomy, posts page, single post, page, or author |
3456 * query variable. After it is set up, it will be returned. |
3473 * query variable. After it is set up, it will be returned. |
3457 * |
3474 * |
3458 * @since 1.5.0 |
3475 * @since 1.5.0 |
3459 * |
3476 * |
3460 * @return object |
3477 * @return WP_Term|WP_Post_Type|WP_Post|WP_User|null The queried object. |
3461 */ |
3478 */ |
3462 public function get_queried_object() { |
3479 public function get_queried_object() { |
3463 if ( isset( $this->queried_object ) ) { |
3480 if ( isset( $this->queried_object ) ) { |
3464 return $this->queried_object; |
3481 return $this->queried_object; |
3465 } |
3482 } |
3605 } |
3622 } |
3606 |
3623 |
3607 /** |
3624 /** |
3608 * Is the query for an existing archive page? |
3625 * Is the query for an existing archive page? |
3609 * |
3626 * |
3610 * Month, Year, Category, Author, Post Type archive... |
3627 * Archive pages include category, tag, author, date, custom post type, |
|
3628 * and custom taxonomy based archives. |
3611 * |
3629 * |
3612 * @since 3.1.0 |
3630 * @since 3.1.0 |
|
3631 * |
|
3632 * @see WP_Query::is_category() |
|
3633 * @see WP_Query::is_tag() |
|
3634 * @see WP_Query::is_author() |
|
3635 * @see WP_Query::is_date() |
|
3636 * @see WP_Query::is_post_type_archive() |
|
3637 * @see WP_Query::is_tax() |
3613 * |
3638 * |
3614 * @return bool Whether the query is for an existing archive page. |
3639 * @return bool Whether the query is for an existing archive page. |
3615 */ |
3640 */ |
3616 public function is_archive() { |
3641 public function is_archive() { |
3617 return (bool) $this->is_archive; |
3642 return (bool) $this->is_archive; |
3992 * Is the query for an existing single page? |
4017 * Is the query for an existing single page? |
3993 * |
4018 * |
3994 * If the $page parameter is specified, this function will additionally |
4019 * If the $page parameter is specified, this function will additionally |
3995 * check if the query is for one of the pages specified. |
4020 * check if the query is for one of the pages specified. |
3996 * |
4021 * |
|
4022 * @since 3.1.0 |
|
4023 * |
3997 * @see WP_Query::is_single() |
4024 * @see WP_Query::is_single() |
3998 * @see WP_Query::is_singular() |
4025 * @see WP_Query::is_singular() |
3999 * |
|
4000 * @since 3.1.0 |
|
4001 * |
4026 * |
4002 * @param int|string|int[]|string[] $page Optional. Page ID, title, slug, path, or array of such |
4027 * @param int|string|int[]|string[] $page Optional. Page ID, title, slug, path, or array of such |
4003 * to check against. Default empty. |
4028 * to check against. Default empty. |
4004 * @return bool Whether the query is for an existing single page. |
4029 * @return bool Whether the query is for an existing single page. |
4005 */ |
4030 */ |
4099 * Works for any post type excluding pages. |
4124 * Works for any post type excluding pages. |
4100 * |
4125 * |
4101 * If the $post parameter is specified, this function will additionally |
4126 * If the $post parameter is specified, this function will additionally |
4102 * check if the query is for one of the Posts specified. |
4127 * check if the query is for one of the Posts specified. |
4103 * |
4128 * |
|
4129 * @since 3.1.0 |
|
4130 * |
4104 * @see WP_Query::is_page() |
4131 * @see WP_Query::is_page() |
4105 * @see WP_Query::is_singular() |
4132 * @see WP_Query::is_singular() |
4106 * |
|
4107 * @since 3.1.0 |
|
4108 * |
4133 * |
4109 * @param int|string|int[]|string[] $post Optional. Post ID, title, slug, path, or array of such |
4134 * @param int|string|int[]|string[] $post Optional. Post ID, title, slug, path, or array of such |
4110 * to check against. Default empty. |
4135 * to check against. Default empty. |
4111 * @return bool Whether the query is for an existing single post. |
4136 * @return bool Whether the query is for an existing single post. |
4112 */ |
4137 */ |
4149 * custom post types)? |
4174 * custom post types)? |
4150 * |
4175 * |
4151 * If the $post_types parameter is specified, this function will additionally |
4176 * If the $post_types parameter is specified, this function will additionally |
4152 * check if the query is for one of the Posts Types specified. |
4177 * check if the query is for one of the Posts Types specified. |
4153 * |
4178 * |
|
4179 * @since 3.1.0 |
|
4180 * |
4154 * @see WP_Query::is_page() |
4181 * @see WP_Query::is_page() |
4155 * @see WP_Query::is_single() |
4182 * @see WP_Query::is_single() |
4156 * |
|
4157 * @since 3.1.0 |
|
4158 * |
4183 * |
4159 * @param string|string[] $post_types Optional. Post type or array of post types |
4184 * @param string|string[] $post_types Optional. Post type or array of post types |
4160 * to check against. Default empty. |
4185 * to check against. Default empty. |
4161 * @return bool Whether the query is for an existing single post |
4186 * @return bool Whether the query is for an existing single post |
4162 * or any of the given post types. |
4187 * or any of the given post types. |