WordPress the_content() return only one image from a specific category

You are trying to get the ID via $post->ID, but that will only return the post ID of the first post. You can use global $post; before the args array, or much simpler replace $post->ID by the function get_the_ID().

$args = array('post_type' => 'attachment', 'numberposts' => 34, 'post_status' => null, 'post_parent' => get_the_ID());

Leave a Comment