How to unindex a single blog in Multisite?

Each site in Multisite has its own search engine setting — in your site’s Admin pages, go to Settings > Reading, and check the Discourage search engines from indexing this site box. The URL should be along the lines of example.com/site-name/wp-admin/options-reading.php

Custom function for search form

bloginfo( ‘template_url’ ) will print the URL to the page and break the return of your function. You need to use get_bloginfo( ‘template_url’ ) to concatenate the result into the string. function clarity_wpsearch($form) { $form = ‘<form role=”search” method=”get” id=”searchform” action=”‘ . home_url( “https://wordpress.stackexchange.com/” ) . ‘” > <label class=”screen-reader-text” for=”s”>’ . __(‘Search for:’, ‘claritytheme’) … Read more

I want empty search returns to home page in my wordpress

This will do exactly what you’re asking for: add_action(‘wp’, ‘redirect_empty_search’); function redirect_empty_search() { global $wp_query; if( isset( $_REQUEST[‘s’] ) && 0 === $wp_query->post_count ) { wp_redirect( home_url() ); exit; } } You’ll want to add some kind of message on the homepage when this happens, maybe by adding a query parameter to home_url() and displaying … Read more

Search form options group categories

You can use in search query wp public query vars. When searching in multiple categories, wordpress accepts comma separated category ids in url &cat=1,2,5 Now I can come up with only such simple solution. Get rid of wp_dropdown_categories use e.g. get_categories, so you can customize SELECT attribute name into cat[] (which is also possible with … Read more

Search using WP_Query

Add this line – <?php $search_query[‘post_type’] = ‘products’; ?> Just before the line – <?php $search = new WP_Query($search_query); ?>

Change /search to /somethingelse

Ok, the solution I’m now using is to create a rewrite rule in .htaccess (on the root of wp project) like this: RewriteCond %{QUERY_STRING} ^s=([^\&]*)$ RewriteRule ^(.*)$ /pesquisar/%1 [NE,L,R=301] I don’t know if it’s the best solution but seems to be working ok!

Ignore image urls in wp_query search

You just need to add post_type argument like this: $wp_query = new WP_Query( array( ‘s’ => $_GET[‘s’], ‘post_type’ => array( ‘post’, /* add more post types if need be */ ), ) ); Read the codex article about WP_Query class for more information.