WordPress.org

Ready to get started?Download WordPress

Forums

attachment from media library (1 post)

  1. eyouth
    Member
    Posted 1 year ago #

    I have this problem getting the post_attachment. This attachment is an image from media library and I attach it to another post. So to say using this helper function

    $args = array( 'post_type' => 'attachment', 'numberposts' => null, 'post_status' => null, 'post_parent' => $post->ID );

    $attachments = get_posts($args);

    it returns nothing. This is maybe because the image that I attach is already assigned to another post, so meaning it has already post_parent assign to it.

    using this helper function..

    get_children( array('post_parent' => get_the_ID(), 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') )

    returns nothing also.

Topic Closed

This topic has been closed to new replies.

About this Topic