Second page (and next) of search results redirects me to the home page
Solved changing the location block with this: location / { try_files $uri $uri/ /index.php?$args; }
Solved changing the location block with this: location / { try_files $uri $uri/ /index.php?$args; }
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
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
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
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
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
get_post() returns the post object to the loop. So when you look for its ->ID if no object is there you try to make php to look for ID of nothing, and it gives you the notice. Change post->ID for if( ! get_post() )
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
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
As noted above, when I tried that code I ended up on a server level 404 page. If this is meant to be a standard WordPress search ( ia m not sure if it is) you need to be using name=”s” and not name=”q”. WordPress uses the s GET variable for a search. The following … Read more