Created
June 12, 2019 18:17
-
-
Save carmoreira/9776e1c43ae4102b7309483abc8d473c to your computer and use it in GitHub Desktop.
team showcase search by title only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'pre_get_posts', 'team_search_by_name_only' ); | |
| function team_search_by_name_only( $query ) { | |
| global $wp_query; | |
| if ( ! is_admin() && in_array ( $query->get( 'post_type' ), array( 'tshowcase' ) ) && $query->is_search() ) { | |
| $query->set( 'meta_key', '_ts_lastname' ); | |
| $query->set( 'meta_value', $query->get( 's' ) ); | |
| $query->set( 'meta_compare', 'LIKE' ); | |
| unset( $query->query_vars[ 's' ] ); | |
| return; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment