Astra_Target_Rules_Fields::search_only_titles( (string) $search, (WP_Query) $wp_query )
Return search results only by post title.
Description
This is only run from astra_get_posts_by_query()
Parameters
- $search
-
((string)) (Required) Search SQL for WHERE clause.
- $wp_query
-
((WP_Query)) (Required) The current WP_Query object.
Return
((string)) The Modified Search SQL for WHERE clause.
Source
File: classes/modules/target-rule/class-astra-target-rules-fields.php
public function search_only_titles( $search, $wp_query ) { if ( ! empty( $search ) && ! empty( $wp_query->query_vars['search_terms'] ) ) { global $wpdb; $q = $wp_query->query_vars; $n = ! empty( $q['exact'] ) ? '' : '%'; $search = array(); foreach ( (array) $q['search_terms'] as $term ) { $search[] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like( $term ) . $n ); } if ( ! is_user_logged_in() ) { $search[] = "$wpdb->posts.post_password = ''"; } $search = ' AND ' . implode( ' AND ', $search ); } return $search; }
Expand full source code Collapse full source code View on Trac