Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active April 3, 2021 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewlimaza/5fb04014d6b6a07f1d8476ded2e48583 to your computer and use it in GitHub Desktop.
Save andrewlimaza/5fb04014d6b6a07f1d8476ded2e48583 to your computer and use it in GitHub Desktop.
Change excerpt length for non-members only (Paid Memberships Pro)
<?php
/**
* Change the excerpt length using PHP for non-members
* Add this function to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_non_member_excerpt_length( $length ) {
if ( ! pmpro_hasMembershipLevel() ) {
$length = 200; // Change the number of characters for non-members.
}
return $length;
}
add_filter( 'excerpt_length', 'pmpro_non_member_excerpt_length', 20 );
@kimwhite
Copy link

The filter function needs to change to match the filter name.

@andrewlimaza
Copy link
Author

Thanks, fixed it :)

@laurenhagan0306
Copy link

This recipe is included in the blog post on "How to show a longer post excerpt for non-members and SEO.
How to show a longer post excerpt for non-members and SEO." at Paid Memberships Pro here: https://www.paidmembershipspro.com/how-to-show-a-longer-post-excerpt-for-non-members-and-seo/

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