Created
March 21, 2022 16:00
-
-
Save abdulawal39/675ba6490af1b19ecb349f0fc23134b8 to your computer and use it in GitHub Desktop.
Exclude PDF Viewers from WordPress Search Results.
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
/** | |
* Please add this code in your active theme's functions.php file | |
* This will exclude PDF Viewer from WordPress Search Results | |
*/ | |
add_action( 'init', 'tnc_hide_pvfw_search', 99 ); | |
function tnc_hide_pvfw_search() { | |
global $wp_post_types; | |
if ( post_type_exists( 'pdfviewer' ) ) { | |
$wp_post_types['pdfviewer']->exclude_from_search = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment