Go to Relevanssi settings in the admin dashboard, click the “Help” on the top right corner of the page, and see “Exclusions”. There’s a bit of code you can use to exclude tagged posts during indexing.
Thread Starter
Jellico
(@catsfoto1se)
Thx, that’s great, ehum, for a WordPress newbie, where should I add the filter hook code?, What file?
Theme functions.php is a very good place.
Thread Starter
Jellico
(@catsfoto1se)
Didn’t get it to work.
I added:
add_filter( 'relevanssi_do_not_index', 'rlv_index_filter', 23, 2 );
function rlv_index_filter( $block, $post_id ) {
if ( has_term( 'jazz', 'genre', $post_id ) ) {
$block = true;
}
return $block;
In my theme functions.PHP
And the tag I’d is 23, it still index it.
And what does the word jazz and genre do in the code?
I even tried to change from jazz to the name of the tag that was going to be excluded, but the same result
A tip to help us newbies, is to explain what in a code that we need to change..
-
This reply was modified 7 years, 9 months ago by
Jellico.
“jazz” is the name of the taxonomy term, “genre” is the taxonomy. So now you’re blocking all documents which have the “genre” set to “jazz”.
If your tag name is “don’t list me” and it’s a regular tag, you have:
add_filter( 'relevanssi_do_not_index', 'rlv_index_filter', 10, 2 );
function rlv_index_filter( $block, $post_id ) {
if ( has_term( "don't list me", 'post_tag', $post_id ) ) {
$block = true;
}
return $block;
}