mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
Query:
Add a query var, `title`, that allows you to query posts by `post_title`. To accomplish this now, you have to do something like: {{{ $tacos = get_posts( [ 'post_type' => 'taco', 's' => $name, 'exact' => true, 'sentence' => true, 'post_status' => 'publish', 'fields' => 'ids', 'posts_per_page' => 1 ] ); }}} Adds unit tests. Fixes #33074. Built from https://develop.svn.wordpress.org/trunk@33706 git-svn-id: http://core.svn.wordpress.org/trunk@33673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
42b6ac80e7
commit
523b51a359
@ -15,7 +15,7 @@ class WP {
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type');
|
||||
public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'title');
|
||||
|
||||
/**
|
||||
* Private query variables.
|
||||
|
@ -1425,6 +1425,7 @@ class WP_Query {
|
||||
, 'preview'
|
||||
, 's'
|
||||
, 'sentence'
|
||||
, 'title'
|
||||
, 'fields'
|
||||
, 'menu_order'
|
||||
);
|
||||
@ -1544,6 +1545,7 @@ class WP_Query {
|
||||
* true. Note: a string of comma-separated IDs will NOT work.
|
||||
* @type array $tax_query An associative array of WP_Tax_Query arguments.
|
||||
* {@see WP_Tax_Query->queries}
|
||||
* @type string $title Post title.
|
||||
* @type bool $update_post_meta_cache Whether to update the post meta cache. Default true.
|
||||
* @type bool $update_post_term_cache Whether to update the post term cache. Default true.
|
||||
* @type int $w The week number of the year. Default empty. Accepts numbers 0-53.
|
||||
@ -1577,6 +1579,7 @@ class WP_Query {
|
||||
$qv['author'] = preg_replace( '|[^0-9,-]|', '', $qv['author'] ); // comma separated list of positive or negative integers
|
||||
$qv['pagename'] = trim( $qv['pagename'] );
|
||||
$qv['name'] = trim( $qv['name'] );
|
||||
$qv['title'] = trim( $qv['title'] );
|
||||
if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
|
||||
if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
|
||||
if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']);
|
||||
@ -2605,6 +2608,10 @@ class WP_Query {
|
||||
unset($ptype_obj);
|
||||
}
|
||||
|
||||
if ( '' !== $q['title'] ) {
|
||||
$where .= $wpdb->prepare( " AND $wpdb->posts.post_title = %s", stripslashes( $q['title'] ) );
|
||||
}
|
||||
|
||||
// Parameters related to 'post_name'.
|
||||
if ( '' != $q['name'] ) {
|
||||
$q['name'] = sanitize_title_for_query( $q['name'] );
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-33705';
|
||||
$wp_version = '4.4-alpha-33706';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user