Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save travislima/e54ada550bd8526995acbb7260624b6a to your computer and use it in GitHub Desktop.

Select an option

Save travislima/e54ada550bd8526995acbb7260624b6a to your computer and use it in GitHub Desktop.
Add "Pages" to PMPro Limit Post Views
<?php // Careful not to copy this php tag.
/**
* Add 'pages' for Limit Post Views Add On for Paid Memberships Pro. You may also add your custom post types using this function below.
* Requires the Paid Memberships Pro - Limit Post Types Add On to work: https://www.paidmembershipspro.com/add-ons/pmpro-limit-post-views/
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_lpv_add_my_post_types( $post_types ) {
// Add pages to post type array to restrict Limit Post Views.
$post_types[] = 'page';
// $post_types[] = 'custom-post-type'; | Example of how you can add more $post_types
return $post_types;
}
add_filter( 'pmprolpv_post_types', 'pmpro_lpv_add_my_post_types', 10, 1 );
@laurenhagan0306

Copy link
Copy Markdown

This recipe is included in the blog post on "Offer limited access to restricted page or CPT content using the Limit Post Views Add On." at Paid Memberships Pro here: https://www.paidmembershipspro.com/offer-limited-access-to-restricted-page-or-custom-post-type-content-using-the-limit-post-views-add-on/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment