Hello,
I am trying to get attachments to show on a category page that are appropriate to that category, to do this I am naming them with a ‘prefix’ I guess of that pages category so for example;
the category is named: Sunny Photos
and an attachment might be named: Sunny Photos Photo Number 1.
So I am trying to check a substring against the category title and if that works then show the attachment properties (title link etc)
My current code is :
<?php
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null );
$attachments = get_posts( $args );
if ($attachments) {
foreach ( $attachments as $post ) {
if(single_cat_title() == substr(the_title(), 0, $catlength)){
setup_postdata($post);
the_title();
the_attachment_link($post->ID, false);
the_excerpt();
}
}
}
?>
this still seems to return all of the attachments from the whole site rather then the ones specified for the category, any help would be greatly appreciated