WordPress.org

Ready to get started?Download WordPress

Forums

Get media info based on media id (2 posts)

  1. floweringmind
    Member
    Posted 4 years ago #

    I want to do a query to get the info of a graphic in the media library and get the title and description. I know the ID of the graphic but not sure how I would do this.

    Does it require me to do a mysql query?

    Chris

  2. floweringmind
    Member
    Posted 4 years ago #

    I figured it out. By the way I am using the attachment plugin but wanted the title and description of the image so that I didn't have to re-enter it every time.

    $querystr = "SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = ".$attachments[$i]['id'];
    $pageposts = $wpdb->get_results($querystr, OBJECT);
    echo $pageposts[0]->post_title;
    echo $pageposts[0]->post_content;

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.