Partial searches for wp_usermeta

<?php // ALWAYS sanitize user input! $poblacion = sanitize_text_field( $_GET[‘poblacion’] ); $trabajo = sanitize_text_field( $_GET[‘trabajo’] ); $usuarios = get_users( array( ‘role’ => ’empresa-BBDD’, ‘order_by’ => ‘nicename’, ‘order’ => ‘ASC’, ‘meta_query’ => array( // search for user meta data ‘relation’ => ‘AND’, array( ‘key’ => ‘poblacion’, ‘value’ => $poblacion, ‘compare’ => ‘LIKE’ // partial comparison ), … Read more

Modify search form with plugin

Here’s an alternative way to only make the product post type searchable, from a plugin code: <?php /** Plugin Name: Product Search Only **/ add_filter( ‘register_post_type_args’, function( $args, $post_type ) { $args[‘exclude_from_search’] = true; if( ‘product’ === $post_type && (bool) $args[‘public’] ) $args[‘exclude_from_search’] = false; return $args; }, 999, 2 ); Here we modify the … Read more

making a search.php query

You are missing the search parameter in your arguments. The code below, when added to the array in $the_query, should pass along the query string variable from a search: ‘s’ => $s Documentation is available here: https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter

Include images from pages in wp search.php results in default wp search

To include the attachment (media) post type in search results, use the following code snippet function attachment_search( $query ) { if ( $query->is_search ) { $query->set( ‘post_type’, array( ‘post’, ‘attachment’ ) ); $query->set( ‘post_status’, array( ‘publish’, ‘inherit’ ) ); } return $query; } add_filter( ‘pre_get_posts’, ‘attachment_search’ ); Source However, this does not take care of … Read more

Search custom post type result in same template page

1.Create a single-(cpt).php in your theme, duplicate a your single.php and rename it as per your CPT name, so this page template will use to show your CPT queries. For more details refer the wordpress codex. https://codex.wordpress.org/Category_Templates To create CPT arcive page follow the same proceduare. archive-(cpt).php For Taxonimies taxonomy-(cpt).php CPT is your custom post … Read more