How to remove date, author and comment count from Chameleon search results page

If the theme doesn’t have a search.php file, index.php will be used. Template_Hierarchy Template file used to render a Search Results Index page search.php index.php [update] Use the following to print the current template being used to render a page: add_filter( ‘the_content’, ‘so_9405896_the_content_filter’, 20, 1 ); function so_9405896_the_content_filter( $content ) { if( is_admin() || !current_user_can( … Read more

Search form as list item in menu?

You can add any item you want to a menu by filtering wp_nav_menu_items. From the tutorial How to Add a Search to Menu, this is how you’d add a search form: add_filter(‘wp_nav_menu_items’,’add_search_box’, 10, 2); function add_search_box($items, $args) { $searchform = get_search_form( false ); $items .= ‘<li>’ . $searchform . ‘</li>’; return $items; }

How to exclude custom fields from search queries?

If I understand you correctly, you need to have post metas in your query. This is where the meta_query parameter of the WP_Query class comes to help. The meta_query is an array of arrays. Example from the codex: $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘age’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => … Read more

Custom field Search with Relavanssi

I don’t have Relevansii installed but it looks like you can hook to relevanssi_search_ok and return false, and Relevansii will pass back the unmodified search. add_filter(‘relevanssi_search_ok’, ‘__return_false’); I am going to assume that Relevansii is using the ordinary search form provided by the theme, meaning that you could modify, or create, searchform.php to include the … Read more

How to Add Additional Search Button?

You might have to check which button was clicked by user, weather it is search all post or search my post, based on that you can apply filter. Try this.. function search_author($query) { if($query->is_search) { if($query->query_vars[‘author’]==’Search My Posts’) { $query->set(‘author’, get_current_user_id()); } } return $query; } add_filter(‘pre_get_posts’,’search_author’);

How to exclude the word “class” from being matched in search?

You might try to use the posts_search filter as elegantly suggested by @Kaiser in the first link you provided. Here is one idea: function filter_search($sql){ global $wpdb; if( strpos(get_query_var(“s”),”lass”) !== false AND strpos(get_query_var(“s”),”class”) === false ){ $sql .= ” AND {$wpdb->posts}.post_title NOT LIKE ‘%class%'”; $sql .= ” AND {$wpdb->posts}.post_content NOT LIKE ‘%class%'”; } return $sql; … Read more

Dashboard search function doesn’t work well

Your issue is with the modification to the site search. You need to restrict your filter more. To prevent it executing on the backend add a negated is_admin() condition. add_filter( ‘pre_get_posts’, ‘tgm_cpt_search’ ); function tgm_cpt_search( $query ) { if ( !is_admin() && $query->is_search ) $query->set( ‘post_type’, array( ‘page’) ); return $query; }; That filter is … Read more