Search for two strings in WP search

I am not 100% sure what you are trying to accomplish, but you can “search for both strings” simply by concatenating them: function checkForAa($query){ if($query->is_search){ $search_string = $query->get( ‘s’ ); if( stripos( $search_string , ‘aa’ ) !== false){ $new_string = str_ireplace( ‘aa’ , ‘xxx’ , $search_string ); }elseif( stripos( $search_string , ‘å’ ) !== false){ … Read more

Custom Query Content Filtering

I assume that your posts are having make and model as a Custom Fields and you want to retrieve all those posts which are matching both the passed value for make and model Custom Fields. If that is the case then your code seems to be correct. It might be possible that there is no … Read more

Search Results Page outputs HTML code

There is most likely a problem with escaping HTML in your code. You might be doing something like this: echo esc_html(“Search Results for: <span>search_word</span>”); Instead, use printf or only wrap your search word with esc_html(): printf(‘Search Results for: <span>%s</span>’, esc_html( $search_word ) ); Update The search results are rendered by search.php, most of the times … Read more

How to get started?

I recommend the following WordPress plugin: https://wordpress.org/plugins/advanced-custom-fields/ This allows you to put custom fields in each post or CPT like the following: Text Textarea Range CheckBox Radio button Select Date Picker Date Time Picker Wysiwyg Editor etc… For the fields FROM STOP,TO STOP,START HOUR and END HOUR you can use: Select and Date Time Picker

why pre_get_posts works fine in post type archive, but not in search result list?

If searching via WordPress ?s=keyword (not WooComm’s Product Search), post_type isn’t set or used, so the following would return false: if( isset($query->query_vars[‘post_type’]) && $query->query_vars[‘post_type’] == ‘product’ ) { You can explore what $query->query_vars contains on your Products page vs your Products Search page by just printing it and killing the page: function my_pre_get_posts( $query ) … Read more

Trying to remove plural ‘s’ from search Query but it’s just removing every letter of the end – what am I doing wrong? Thanks

Try this: function mySearchFilterFunction($query) { if ( !is_admin() && $query->is_main_query() && $query->is_search) { $search_term = $query->get(‘s’); if (substr($search_term, -1) == ‘s’){ $search_term = substr($search_term, 0, -1); } $query->set(‘s’, $search_term); } } add_action( ‘pre_get_posts’, ‘mySearchFilterFunction’);

Search Results No Link

The problem is in this part <?php if ( is_search() ) : // Only display Excerpts for Search ?> <div class=”entry-summary”> <div class=”entry”> <?php $content = get_the_content(); $content = strip_tags($content); echo ‘<p>’ . substr($content, 0, 255) . ‘ […] </p>’; ?> <hr class=”post-divider”/> </div> </div> <?php else : ?> You need to add a link … Read more

How to combine two get_users() array?

Edit: to clarify, the answer to How can I merge them together for results? Is that you really can’t, not without a lot of custom SQL and using filters. The complexity of going that route far outweighs any perceived benefits and wouldn’t be very future-proof. I’d recommend using the solution below and putting it all … Read more

How to have search results page sorted by post date

WordPress will order search results by newest post first by default, so if your results are in a different order then it looks like another plugin is affecting them. Have you tried searching with all other plugins disabled? If you’re using Relevanssi, then it won’t order results by date as Relvanssia overrides this with its … Read more