I want to use this script to list all the attachments paths for posts of a particular category:
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'category' => 61
);
$the_attachments = get_posts( $args );
if ($the_attachments) {
foreach ( $the_attachments as $post ) {
setup_postdata($post);
echo get_attached_file( $post->ID ) . "<br />";
}
} wp_reset_query();
?>
But the problem is it doesn't do anything unless I remove the 'category' arg, in which case it shows ALL attachment paths regardless. But I only want it for category 61.
I've triple checked and there are indeed posts that contain attachments in category 61.
What am I doing wrong?
Thanks in advance.