Hi,
I’m trying to add S2Member’s query filters to a query that’s contained inside a custom shortcode. Below is the initial part of the query. The rest of the shortcode (not shown here) just displays the custom posts from the query by adding them to the $output variable and then returning $output.
The attach_s2member_query_filters(); isn’t working and all the posts are being displayed by the shortcode to all site visitors regardless of member level. I tried adding attach_s2member_query_filters() to the $query variable but that didn’t work, either. Is there a way to use attach_s2member_query_filters() in this situation? I know it’s a bit unusual.
If not, is there another way to limit a query like this to specific user levels (maybe by adding something to the $args array)? If so, I could run two separate queries, one for users above a certain level, and another for users below that level, and use the [s2If !current_user_can(access_s2member_level)] shortcode on the actual page to display different queries depending on the user’s member level. That would be fine as well.
Thanks in advance for any help or advice!
Matt
Here’s the query from the shortcode that isn’t filtering properly:
$args = array(
‘post_type’ => ‘custom_item’,
‘posts_per_page’ => 20,
‘order’ => ‘ASC’
);
attach_s2member_query_filters();
$query = query_posts($args);
$output .= get_the_posts_pagination();
//start loop
if (have_posts($query)) : while (have_posts($query)) : the_post();