Only display post content in search results

Some themes like Twenty Fourteen include a template tag included in the content.php file for entry meta which includes the author and date: Example: twentyfourteen_posted_on(); The content.php file also includes the_title() tag so you need to remove that if you don’t want the entry titles displaying on your search result pages. The search.php file includes … Read more

Specific website content

You will want to register custom post types for each of the sections (books, articles, etc). Your post types should be registered as a custom plugin so that they can be kept in the case you decide to switch your theme. Custom post types: http://codex.wordpress.org/Post_Types WordPress plugin API: http://codex.wordpress.org/Plugin_API The advanced search is a bit … 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

How to search for post content and attached file names

If you look at the $wpdb->posts table in the database, you will notice that the file names, minus the file type ending, are used for the post_title for attachments. This means that you can effectively search the file name if you can get your search function to search attachments, which the default search (almost) already … Read more

My default search is not working

It is better to modify WordPress search SQL query instead of adding extra meta query. try this: function search_distinct($distinct) { $distinct=”DISTINCT”; return $distinct; } function join_table($join){ global $wpdb; $join .= “LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) “; return $join; } function search_into_post_meta( $search, $wp_query ) { if ( is_search() ) { global $wpdb; if … Read more

Prevent searches less than 4 characters

You can use the pattern attribute to ask for at least 3 characters: <input pattern=”.{3,}”> But if your database dies just because someone searches for a three letter word … you have other problems than search. Optimize your database instead, or find another solution. A simple search, even dozens per minute should not be a … Read more