Duplicate Snippet
Embed Snippet on Your Site
MemberPress: ACF – Exclude Protected Posts From ACF Repeater Field
The code snippet ensures that protected MemberPress posts are excluded from custom queries used in Advanced Custom Fields (ACF) repeater fields. This prevents these posts from being displayed to unauthorized users.
To exclude protected posts based on the specific post type, modify the get_posts array to include the specific post type.
The get_post_types() should be replaced by the required post type, on this line:
'post_type' => get_post_types(),
For example, to exclude all posts with the custom post type called events, the mentioned line of the code would look like this:
'post_type' => 'events',
Code Preview
php
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Comments