Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sc0ttkclark/98c85bb7aa791a2b341ef0221297da8f to your computer and use it in GitHub Desktop.
Save sc0ttkclark/98c85bb7aa791a2b341ef0221297da8f 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.
<?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