I created a custom function for this, but if you want the root folder id, you can use the wp cli
and use the command wp term list wpmf-gallery-category
to show all the gallery folders. Get the term id of the one you want to use as the root and set it to $master_id
/*
get_root_gallery_id();
Custom function that returns the id of folder with parent id == 0
*/
$master_id = get_root_gallery_id( 'master' );
$galleries = get_terms( 'wpmf-gallery-category', [ 'hide_empty' => 0 ]);
// If there is a root folder
if ( $master_id )
{
foreach ( $galleries as $gal )
{
if ( $gal->parent == $master_id )
{
$args = [
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_status' => 'inherit'
'tax_query' => [
[
'taxonomy' => 'wpmf-gallery-category',
'terms' => [ $gal->term_id ],
'field' => 'term_id'
]
]
];
$query = new WP_Query( $args );
if ( $query->have_posts() )
{
while ( $query->have_posts() )
{
$query->the_post();
global $post; // Image as Post Object
}
}
}
}
}