Tag Info

Hot answers tagged

1

If you want to exclude certain posts, wouldn't the conditional be: if ($value != '' && get_post_meta($post->ID, 'value', true) != 'value_to_exclude') Anyhow, you're excluding AFTER you run the query. So $total_results will always be 'wrong'. The better approach is to write sql for WP_Query that does the excluding for you. But you didn't ...


1

You don't really need to use the &new WP_Query just new WP_Query. The following code will resolve your problem. add_filter( 'posts_search', 'q166788_search_modify', 10, 2 ); function q166788_search_modify( $sql, $query ){ // Only if our variable is true we do the black magic if ( ! isset( $query->query_vars['search_conditional_toggle'] ) || ...


1

You can hook into the 'get_search_form' action hook ( check out the "last option" part of the link below ). Set the priority high enough to override anything created in a theme. A plugin could look like ( from the link below ): function my_search_form( $form ) { $form = '<form role="search" method="get" id="searchform" class="searchform" action="' ...


1

Search code comes with wordpress.If you remove search box it does not mean that search page is removed. If you want that google should not crawl your search page then you can specify in your robot.txt file like below : Disallow: /search



Only top voted, non community-wiki answers of a minimum length are eligible