Created
January 6, 2022 14:53
-
-
Save ideadude/96817c610f9a033dab979b8cde3e90c2 to your computer and use it in GitHub Desktop.
Also hide members-only "products" CPT from archives.
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 | |
/** | |
* Also hide members-only "products" CPT from archives. | |
* You must use the PMPro CPT Add On and then check a produc to require membership. | |
* And also set the "Filter searches and archives?" option to Yes in the PMPro advanced settings. | |
*/ | |
function my_hide_members_only_products_from_archives( $post_types ) { | |
if ( ! in_array( 'product', $post_types ) ) { | |
$post_types[] = 'product'; | |
} | |
return $post_types; | |
} | |
add_filter( 'pmpro_search_filter_post_types', 'my_hide_members_only_products_from_archives' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment