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

WP_User_Query not searching

WP_User_Query searches the $wpdb->users table. It will not join on your custom table. How would it know what to JOIN? The possible tables names and structures are practically infinite. I believe you might be able to use a filter on pre_user_query to insert your own values in the WHERE clause but there is no JOIN … Read more

WordPress custom search by post type

Yes, it is possible. You will have to use your custom SQL query though. Use posts_where filter to modify the query. function posts_where( $where ) { if( !is_admin() ) { $where = <YOUR CONDITION>; } return $where; } add_filter( ‘posts_where’ , ‘posts_where’ ); Your condition should look something like this: post_status=”publish” AND ((post_type=”post” AND post_title … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)