Created
June 25, 2020 19:21
-
-
Save kimcoleman/14ab0d1141a8e456e7db2bfdbcad96f2 to your computer and use it in GitHub Desktop.
Hide specific post types created using the Pods framework from searches and archives if membership is required to access.
This file contains hidden or 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 | |
/** | |
* Hide the 'my_pods_item' post type from searches and archives if membership is required to access. | |
* Update the $post_types[] array with one or more pod names you need to protect. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function hide_my_pods_item_filter_post_types( $post_types ) { | |
$post_types[] = 'my_pods_item'; | |
return $post_types; | |
} | |
add_filter( 'pmpro_search_filter_post_types', 'hide_my_pods_item_filter_post_types' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment