A Cozmoslabs Product
Documentation / Developer Knowledge Base / Show Excerpt instead of Content Restriction message on Category Archive pages

Show Excerpt instead of Content Restriction message on Category Archive pages

By default, if a restricted post is shown in the Category Archive, the content will be replaced with the Content Restriction message that you configured.

With the custom code from below, we can make the posts show the Excerpt on the Category Archive pages and only when the user clicks on a post to see the whole content, they will see the restriction message.

add_filter( 'pms_content_restriction_message', 'pmsc_cr_show_excerpt_in_category_pages', 20, 3);
function pmsc_cr_show_excerpt_in_category_pages( $message, $message_type, $post_id) {
	if ( !is_archive() || empty($post_id) ) return $message;
	
	$excerpt = get_the_excerpt( $post_id );

	if ( !empty($excerpt) )
		return $excerpt;
	else
		return $message;
}

Paid Member Subscriptions Pro

Accept (recurring) payments, create subscription plans and restrict content on your website. Easily setup a WordPress membership site using Paid Member Subscriptions.

Get Paid Member Subscriptions

The Ultimate Membership Bundle

Combine the power of Profile Builder with Paid Member Subscriptions to set up user registration, memberships, and recurring revenue.

Get 25% off with the bundle

Help & Support

We’re here to help you every step of the way.

Open a Support Ticket