BuddyDev

Search

[Resolved] MediaPress shortcode parameter to not show empty galleries

  • Participant
    Tom on #38564

    Hi there, is there a parameter for MediaPress shortcodes to not show empty galleries?
    As you can see here https://piratemc.com/gallery/
    A user created 3 empty galleries on their profile, which for some reason are shown?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1796
    Ravi on #38565

    Hello Tom,

    Thank you for posing. Currently, Gallery shortcode is not supported hiding empty gallery feature. But you can use the following code in Active Child Theme “functions.php” or “bp-cutom.php” file:

    
    add_filter( 'mpp_shortcode_list_gallery_query_args', function ( $args ) {
    
    	$meta_query = array(
    		array(
    			'key'     => '_mpp_media_count',
    			'value'   => 1,
    			'compare' => '>=',
    		),
    	);
    
    	if ( isset( $args['meta_key'] ) ) {
    		$meta_query[] = array( 'key' => $args['meta_key'] );
    
    		unset( $args['meta_key'] );
    	}
    
    	$args['meta_query'] = $meta_query;
    
    	return $args;
    } );
    
    

    It will hide all empty galleries listed using gallery shortcode. Please give it a try and let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 5
    Gav on #38571

    I had the same issue, used this snippet and it worked perfectly. Cheers Ravi.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 1796
    Ravi on #38573

    Hello Gav,

    Thank you for the acknowledgment. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] MediaPress shortcode parameter to not show empty galleries’ is closed to new replies.

This topic is: resolved