post_parent problem
-
Hi,
‘post_parent’ => $post->ID returns a blank page, when using null it works, but that’s not what I want. I want to collect the attachments of its parent (or a specified post).
Does anybody know what’s the problem?
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $wp_query = new WP_Query(); $wp_query -> query('category_name=photo&posts_per_page=1&order=ASC&paged=' . $paged); ?> <?php while($wp_query -> have_posts()) : $wp_query -> the_post(); ?> <?php if(is_paged()){ ?> <?php $args = array( 'post_type' => 'attachment', 'numberposts' => 25, 'post_parent' => $post->ID, 'order' => 'ASC' ); $attachments = get_posts($args); if($attachments){ foreach($attachments as $attachment){ $atturl = wp_get_attachment_thumb_url($attachment->ID); $attlink = get_attachment_link($attachment->ID) . '&paged=' . $paged; echo '<a href="' . $attlink . '"><img src="' . $atturl . '"></a>'; } }; ?> <?php } else { ?> <?php the_content(); ?> <?php }; ?> <?php endwhile; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘post_parent problem’ is closed to new replies.