Show 1 media per cat in a loop
-
I want to display one image per category (media category) in a custom loop.
I have that but it’s doesn’t work
-
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
- ‘;
echo wp_get_attachment_image( $attachment->ID, ‘full’ );
echo ‘<p>’;
echo apply_filters( ‘the_title’, $attachment->post_title );
echo ‘</p>
$args = array(
‘post_type’ => ‘attachment’,
‘numberposts’ => -1,
‘post_status’ => null,
‘child_of’ => 34);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo ‘‘;
}
}endwhile; endif; ?>
anyone know how can i do this?
- ‘;
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Show 1 media per cat in a loop’ is closed to new replies.