Skip to content

Instantly share code, notes, and snippets.

@msaari
Last active January 18, 2023 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msaari/261a9ef2ab7decc0caf6e1bf4e6162d8 to your computer and use it in GitHub Desktop.
Save msaari/261a9ef2ab7decc0caf6e1bf4e6162d8 to your computer and use it in GitHub Desktop.
Only index PDF attachments for Relevanssi
<?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
Copy link

how to allow pdfs too ?

@msaari
Copy link
Author

msaari commented Jan 18, 2023

@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