Skip to main contentSkip to footer

If you’re using category restriction dropdown on your search form, here’s a bit of code that you can add to your search results template to show how many hits were found and what the category is. If no category was selected, this’ll just show how many hits were found.

<?php
    $cat = get_cat_name( $wp_query->query_vars['cat'] );
    $s = $wp_query->query_vars['s'];
    echo $wp_query->found_posts . " results found with ' $s'";
    if ( ! empty( $cat ) ) {
        echo " in the '$cat' category";
    }
?>

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Modernize
Modernize is a neat Premium theme that has a problem with Relevanssi. Relevanssi highlighting can cause problems on Modernize search…
WP Download Manager

…these issues. When you upload the files to the Relevanssi attachment reading server, Relevanssi uses the get_attached_file() function to get the file name, but that does not work with WP Download Manager. Thus we need to use the relevanssi_get_attached_file filter hook to provide the file name and path for Relevanssi….…add-on adds an advanced search with the [wpdb_archive_filter] shortcode. That search does not use Relevanssi by default, but it can be modified to make use of Relevanssi with this little function you can add to your site: add_filter( ‘wpdm_packages_query_params’, ‘rlv_use_relevanssi’ ); function rlv_use_relevanssi( $params ) { if ( isset( $params[‘s’]…

Related Posts:

Comment Section:

1 Comment. Leave new

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed