Tagged: code, mediapress-snippet
Hi Brajesh,
I’ve got a new option request, I’d like to hide empty galleries from the edit.php gallery browser. Would that be possible. You see on my site I’ll be creating galleries in anticipation of future content, there’s no need for the users to see empty galleries as that will be uploading from the from end, so these are just dead-end click zones.
Hi George,
We can do it by using pre_get_posts filter in the admin and looking for _mpp_media_count meta on the galleries.I will post this code later today with the other thread(I am sorry I missed to post a solution there).
Thank you
BrajeshHi George,
Please use the following code/** * Hide empty MediaPress Gallery from admin galleries list. * * @param WP_Query $query query object. */ function mpp_admin_hide_empty_galleries_from_galleries_page( $query ) { if ( ! is_admin() || defined( 'DOING_AJAX' ) || ! $query->is_main_query() ) { return; } if ( $query->get( 'post_type' ) != mpp_get_gallery_post_type() ) { return; } $meta_query = array( array( 'key' => '_mpp_media_count', 'value' => 1, 'compare' => '>=', ), ); // side effect: it will override any other meta query for the galleries list. $query->set( 'meta_query', $meta_query ); } add_action( 'pre_get_posts', 'mpp_admin_hide_empty_galleries_from_galleries_page' );
Hope this helps.
Regards
BrajeshThank you George.
Good to know that 🙂Best Regards
Brajesh
The topic ‘ [Resolved] Mediapress new optin request – Hide Empty Galleries’ is closed to new replies.