can’t limit search to only pages

A quick test on a default install with TwentyEleven confirms this, and I’m not sure why this is the case, however there is a way you can do this via your functions.php. add a hidden field to the form with your own query var: <input type=”hidden” name=”my_type” value=”page” /> or: <input type=”hidden” name=”my_type” value=”post,page” /> … Read more

Turning Broken URLs Into Search Terms?

You can try a plugin to do this: http://wordpress.org/extend/plugins/smart-404/ Reads the page URL and tries to find a page/post that it might match and redirect to it. Found out about this plugin from: http://www.aebeta.com/web-hosting/seo/7-seo-friendly-404-plugin-for-wordpress.html

template_include for search.php makes WordPress think its on the home page

Your problem is that you are not resetting all the needed query variables, like WP_Query::$is_page, WP_Query::$is_single and WP_Query::$is_archive. Also note that ‘pre_get_posts’ is fired for all queries, the main and the secondaries, so you should check that you are working on the main query. Finally, when you get data from $_GETyou should sanitize it before … Read more

Get user role by using user_id in buddypress

Try this function: function get_user_role($user_id){ global $wpdb; $user = get_userdata( $user_id ); $capabilities = $user->{$wpdb->prefix . ‘capabilities’}; if ( !isset( $wp_roles ) ){ $wp_roles = new WP_Roles(); } foreach ( $wp_roles->role_names as $role => $name ) { if ( array_key_exists( $role, $capabilities ) ) { return $role; } } return false; } I’ve not included … Read more

Complex Search functionality. Advice needed

There’s a few ways you could do this. I once wrote some extended code to integrate Apache Solr with WordPress search and BuddyPress and that added a lot of power. With something like Apache Solr you can customize weight and do some interesting things. Solr is a full fledged search engine and you will need … Read more

WordPress 3.6, searchform.php problems

The answer is taken from WordPress.org Support Forum thread: » 3.6 upgrade – searchform.php not working As salcode said: Adding this code to your functions.php should do the trick: function search_form_no_filters() { // look for local searchform template $search_form_template = locate_template( ‘searchform.php’ ); if ( ” !== $search_form_template ) { // searchform.php exists, remove all … Read more