Plugin Author
DeBAAT
(@debaat)
Hai,
Thanks for using this plugin.
I’m not quite sure what you would like to achieve, but this is the set of arguments I use to filter the attachments:
// Get the posts associated with the media_taxonomy
$attachments_args = array(
'showposts' => -1,
'post_type' => 'attachment',
'post_parent' => null,
'tax_query' => array(
array(
'taxonomy' => $media_taxonomy,
'field' => 'slug',
'terms' => $media_categories
)
),
);
You can find this in the function “mcm_get_attachment_ids()“. I use this function when processing the WP_MCM shortcode.
Hope this helps.
Best regards,
Jan
Plugin Author
DeBAAT
(@debaat)
Hai,
And thanks for this feedback.
I checked and the reason it works for me is that I do use get_posts($attachments_args) to get the attachments.
Can we mark this as solved now?
Gr.
Jan
Yes, I am able to use WP_Query to list media, filtered by terms of the “category_media” taxononmy. Thanks!
That said, I still am unable to get the shortcode to work (which is why I tried using WP_Query instead), but i’ll post that in a separate threat.
Plugin Author
DeBAAT
(@debaat)
Ok, thanks!
Looking forward to your description of the issue with the shortcode…
Hello, I’m using:
// Get the posts associated with the media_taxonomy
$attachments_args = array(
'showposts' => -1,
'post_type' => 'attachment',
'post_parent' => null,
'tax_query' => array(
array(
'taxonomy' => $media_taxonomy,
'field' => 'slug',
'terms' => $media_categories
)
),
);
to try to get something like this:
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '<li>';
echo wp_get_attachment_image( $attachment->ID, 'thumbnail' );
echo '<p>';
echo apply_filters( 'the_title', $attachment->post_title );
echo '</p></li>';
}
}
in order to control more of the results as I need to show elements of a subcategory with a special design. I can’t make it to show any result. I used the shortcode (which works perfectly fine) but my problem is that the shortcode doesn’y give me the flexibility I need. It will be very helpful if you can show me how to achieve this.
Thanks