Last active
April 3, 2021 04:13
-
-
Save andrewlimaza/5fb04014d6b6a07f1d8476ded2e48583 to your computer and use it in GitHub Desktop.
Change excerpt length for non-members only (Paid Memberships Pro)
This file contains 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 | |
/** | |
* 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 ); |
Thanks, fixed it :)
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
The filter function needs to change to match the filter name.