Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kimcoleman/14ab0d1141a8e456e7db2bfdbcad96f2 to your computer and use it in GitHub Desktop.
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.
<?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