msaari / relevanssi

Relevanssi, a WordPress plugin to improve the search
GNU General Public License v3.0
49 stars 21 forks source link

relevanssi_render_block not called #52

Closed flavh closed 1 year ago

flavh commented 1 year ago

Hello,

I'm trying to exclude some Gutenberg blocks from Relevanssi indexing by adding a filter with the following code :

add_filter('relevanssi_render_block', 'exclude_block_from_search_render');

function exclude_block_from_search_render($block) {
    error_log('TEST RENDER_BLOCK');
}

The problem is that this function is never called during searches. I've also tried the "relevanssi_hits_filter" filter, which is called, but that's not the one I need.

Is this a premium feature? If not, how can I correct this error?

Thanks for your help

msaari commented 1 year ago

It's not a premium feature. The reason it's not called during searches is because it's an indexing hook: it only happens when the post is indexed. Try saving the post: that should trigger the function.

flavh commented 1 year ago

It all makes sense now, so thank you very much for your quick reply! My problem's solved.