WordPress.org

Ready to get started?Download WordPress

Forums

Attachments on posts not working (1 post)

  1. Niklas
    Member
    Posted 2 years ago #

    I am able to upload images and add them to posts, however when theming I see no images:

    $args = array(
    	            'order'          => 'ASC',
    	            'orderby'        => 'menu_order',
    	            'post_type'      => 'attachment',
    	            'post_parent'    => $post->ID,
    	            'post_mime_type' => 'image',
    	            'post_status'    => 'any',
    	            'numberposts'    => 1,
    
    	        );
    	        $attachments = get_posts($args);
    	        print_r($attachments);

    returns an empty array when used inside the loop. What am I doing wrong?

Topic Closed

This topic has been closed to new replies.

About this Topic