WP_Term_Query::get_search_sql() WordPress Method

The WP_Term_Query::get_search_sql() method is used to get the search SQL for a given search string. This can be used to search for a term in the WordPress database.

WP_Term_Query::get_search_sql( string $search ) #

Used internally to generate a SQL string related to the ‘search’ parameter.


Parameters

$search

(string)(Required)Search string.


Top ↑

Return

(string) Search SQL.


Top ↑

Source

File: wp-includes/class-wp-term-query.php

	protected function get_search_sql( $search ) {
		global $wpdb;

		$like = '%' . $wpdb->esc_like( $search ) . '%';

		return $wpdb->prepare( '((t.name LIKE %s) OR (t.slug LIKE %s))', $like, $like );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.