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

Proximity sorting

…flexible but requires some work. It is not complicated; you must tell Relevanssi where to find the necessary information. Relevanssi works with latitude and longitude values and needs the coordinates in the “61.4898, 23.7735” format, the most common format. Setting up proximity sorting First, you need to enable proximity sorting….Relevanssi Premium 2.16 added proximity sorting to search results. That means you can sort the search results by geographic location. Instead of having the most relevant matches first, you can have the nearest results first. There are many ways to use geolocation in WordPress. The way Relevanssi does this is……Calculating the distances is an extra step, and it’s not turned on by default. Add this to your site to enable proximity sorting: add_filter( ‘relevanssi_proximity_sorting’, ‘__return_true’ ); The next step is to declare the comparison coordinates. Where is the spot against which Relevanssi compares the results? These coordinates can be…

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

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