Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Support request] Protected posts in shortcode

Simple Membership Plugin › Forums › Simple Membership Plugin › Protected posts in shortcode

Tagged: custom shortcode, protected content

  • This topic has 2 replies, 1 voice, and was last updated 5 years, 2 months ago by lijndiensten.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • December 19, 2020 at 10:48 am #21782
    lijndiensten
    Participant

    Hi, we use the shortcode below to show a list posts from a given category, some of which are protected. Now when I include this shortcode on any page, that page – that in itself is not protected – becomes protected content. It seems to be tripping over the fact that it is including content from one or more protected posts.

    Is there a way to use the below shortcode and include also protected posts, but still have the page on which that shortcode is included be accessible as normal? If that is too complicated, would it be possible to simply filter out protected posts from this loop?

    Thanks,
    Ivan

    function bvkm_posts_shortcode()   {
        $args = array( 'posts_per_page' => 4, 'category_name' => 'evenement');                  
        $last_5_posts_query = new WP_Query( $args );
        while($last_5_posts_query->have_posts()) : 
            $last_5_posts_query->the_post();
            $link = get_permalink();
            $title = get_the_title();
            $date = get_the_date();                              
    
            $content .= '<div class="x-recent-posts recent_events cf vertical" data-x-element="recent_posts" data-fade="false">';
            $content .= '<a class="x-recent-post4 no-image" href="'.$link.'" title="Permalink to: '.$title.'" style="outline: none;">';
            $content .= '<article id="post-" class="post type-post status-publish format-standard hentry category-evenement">';
    		$content .= '<div class="entry-wrap"><div class="x-recent-posts-content">';
    		$content .= '<span class="event_datum">' .get_field('event_datum'). '</span>';
    		$content .= '<h3 class="h-recent-posts">' .$title. '</h3>';
            $content .= '<span class="event_metadata"><i class="x-icon x-icon-map-marker-alt" data-x-icon-s="" aria-hidden="true"></i> ' .get_field('event_locatie'). ' <i class="x-icon event_clock_icon x-icon-clock" data-x-icon-s="" aria-hidden="true" style="text-align: center;"></i> ' .get_field('event_aanvangstijd'). '</span>';
    		$content .= '</div></div>';	
    		$content .= '</article>';	
    		$content .= '</a>';
    		$content .= '</div>';
        endwhile;
    
    return $content;
    }
    
    add_shortcode('bvkm_events', 'bvkm_posts_shortcode' );
    December 30, 2020 at 5:46 pm #21830
    lijndiensten
    Participant

    Hi guys, any luck on this one? If this question is beyond normal support and there is an opportunity for paid support, that should also be fine. Thanks.

    January 19, 2021 at 10:26 am #21979
    lijndiensten
    Participant

    Hi, still hoping for an answer here!

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy