Skip to main contentSkip to footer

Jules Colle came up with a method of moving the Relevanssi admin search page from under the Dashboard heading to the top level of the admin menu.

add_action( 'admin_menu', function () {
  remove_submenu_page( 'index.php', 'relevanssi_admin_search' );
  add_menu_page(
    'Search all content',
    'Search all content',
    'manage_options',
    'relevanssi_admin_search',
    'relevanssi_admin_search_page',
    'dashicons-search',
    2
  );
}, 99 );

This function adds an admin_menu action that first uses remove_submenu_page() to remove the existing admin search function and then add_menu_page() to add it again on the top menu level.

This works well except for one thing. The Relevanssi admin javascript is added only to specific pages, and the new location of the admin search page is not one of those.

This problem was solved in version 2.13 (Premium) and 4.11 (free version), when the filter hook relevanssi_acceptable_hooks was introduced. This filter hook lets you add new admin page hooks where Relevanssi javascript is used, so we can introduce our new admin search page:

add_filter( 'relevanssi_acceptable_hooks', function( $hooks ) {
    $hooks[] = 'toplevel_page_relevanssi_admin_search';
    return $hooks;
} );

Now we have a nice, functioning admin search that is not hidden:

Relevanssi admin search in the top menu

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…

Related Posts:

Comment Section:

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