Use Tags to initiate Search

I used a workaround for now. I eddited the category_template.php with the str_replace function. The problem turned out to be that the Tag Cloud used diffenten functions than the regular Tags. I just added this: foreach ( $tags_data as $key => $tag_data ) { $class = $tag_data[‘class’] . ‘ tag-link-position-‘ . ( $key + 1 … 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

Custom Loop Query For Search Page

You have to pass the search query too. To get the search query, you can use the get_search_query() function, and pass it to the query’s s parameter: $search_string = get_search_query(); $args = array( ‘s’ => $search_string, ‘posts_per_page’ => 12, ‘order’ => ‘DESC’, );

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’);