get_query_var(‘s’) not working

Probably you need to use the following function somewhere in your template, whether in functions.php or somewhere. function add_query_vars_filter( $vars ){ $vars[] = “s”; return $vars; } add_filter( ‘query_vars’, ‘add_query_vars_filter’ ); It’ll avail your s parameter from the URL into the get_query_var(‘s’).

Refine Search Results

Search is a big topic and therefore I can only guess the direction you want to go to. Like @MikeSchinkel in his comment was asking for more, I can for the moment only provide a list of links of which one might come close to what you need: Refine search by category (How-To); Building a … Read more

Search form with Category and Sub Category

First you have to give your dropdown names so: <?php $media = array( ‘name’ => ‘subcat’, ‘hierarchical’ => 1, ‘parent’ => get_cat_id(‘Media’), ‘show_option_none’ => (‘All Media’), ‘hide_empty’ => 0 ); ?> <form method=”get” id=”searchform” action=”<?php bloginfo(‘url’); ?>/”> <div> <input type=”text” value=”<?php the_search_query(); ?>” name=”s” id=”s” /> <?php wp_dropdown_categories(‘name=maincat&show_option_none=All Category’); ?> <?php wp_dropdown_categories($media); ?> <input type=”hidden” … Read more

Do not allow to search certain words

Try this in your functions.php, and change news for whatever you want to be blocked in your site. add_action(‘wp’, ‘check_search’); function check_search() { global $wp_query; if (!$s = get_search_query()) return false; if (preg_match(‘/news/’, $s)) { $wp_query->set_404(); status_header(404); get_template_part(404); exit(); } } Hope it helps.

Which template holds what to display when search returns nothing

get_template_part( ‘content’, ‘none’ ); will look for: content-none.php content.php Twenty Thirteen does have content-none.php. In general this is organized in such way to support dynamic lookups where first two-part template might or might not exist and fallback to more generic template, if necessary.

How do I make search results include ONLY pages, no posts?

You can enforce a post type per callback on pre_get_posts: is_admin() || add_action( ‘pre_get_posts’, function( \WP_Query $query ) { $post_type = filter_input( INPUT_GET, ‘post_type’, FILTER_SANITIZE_STRING ); if ( $post_type && $query->is_main_query() && $query->is_search() ) $query->set( ‘post_type’, [ $post_type ] ); }); If that still includes other post types, you have a second callback registered on … Read more

Search Issue in the theme

Every request sent to http://example.com/?s=string will result in a search query, WordPress will use the search.php to render the output. It doesn’t matter where the request is came from. If you need to do an AJAX search, you have to write your own function to do the search and then return it. I have an … Read more

Noindex, nofollow stuck on homepage

The setting is stored in the options table under the key blog_public, the value is either 0 or 1. You can see the value of all options by manually visiting the page /wp-admin/options.php. A quick way to get rid of it would be to remove the noindex action hooked to wp_head, which is what outputs … Read more

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