search custom post type by custom fields on front end

I solved it and share it here if its help some one else add_shortcode(‘user_search’,’My_User_search’); function My_User_search($atts = null){ $out = user_search_form(); $args = array(‘post_type’ => ‘umrahpackage’,’order’ => ‘asc’, ‘meta_query’ => array( array( ‘key’ => ‘country’, ‘value’ => $_GET[‘s_value’], ‘compare’ => ‘Like’, ) ) ); $the_query = new WP_Query( $args ); if( $the_query->have_posts() ): while( $the_query->have_posts() … Read more

Changing the ORDER BY in WordPress default search function

If I were you, I would likely use the posts_search_orderby hook to change the search ORDER BY clause, because that way, the sorting would work with pagination. So for example in your case, you would want to sort by the post type like so: (well, if the “product posts” is of a different post type?) … Read more

Changing default wp search string

By default WordPress use a + between spaces No, it doesn’t. WordPress doesn’t generate + characters, it doesn’t use those characters, and it can’t see them. So Where Does the + Come From? The browser and URLs. Spaces in URL parameters are encoded as + characters or %20. Forms specifically become +. When data that … Read more

Custom search Dashboard widget

Firstly, let’s start off by cleaning up the query you have above. I’ve put it into Heredoc syntax to make it easier to read. $sql = <<<SQL SELECT * FROM {$tablename} — you should use interpolation when working in a string that can have variables WHERE ( — Your query will only ever match one … Read more

Include the post type before the title of search results

I solved this by copying the divi index.php and placing it in my child theme as search.php I then found where the title and altered it with the below code: <h2 class=”entry-title”> <a href=”<?php the_permalink(); ?>”> <?php $post_type = get_post_type( $post->ID ); echo $post_type . “: “; the_title(); ?> </a> </h2> Probably not the correct … Read more