Last active
January 18, 2023 05:31
-
-
Save msaari/261a9ef2ab7decc0caf6e1bf4e6162d8 to your computer and use it in GitHub Desktop.
Only index PDF attachments for Relevanssi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add this to theme functions.php | |
add_filter('relevanssi_do_not_index', 'rlv_only_pdfs', 10, 2); | |
function rlv_only_pdfs($block, $post_id) { | |
$mime = get_post_mime_type($post_id); | |
if (!empty($mime)) { | |
$block = true; | |
if (substr($mime, -3, 3) == "pdf") $block = false; | |
} | |
return $block; | |
} | |
?> |
@zakirsajib, please elaborate: what exactly do you want to be included in the search? By default, nothing is blocked, so PDFs are included.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to allow pdfs too ?