WordPress.org

Ready to get started?Download WordPress

Forums

Working with attachments via plugins (2 posts)

  1. Konstantin Kovshenin
    Member
    Posted 5 years ago #

    Okay, I'm developing a small plugin and it's got some fields in the edit post/page screen. I've got an URL field where I'd like to make this kind of thing: user clicks a button, gets a list of attachments to the current post or page, selects one and its URL appears in the URL box. Are there any wordpress functions for this or do I have to hard-code?

    Thanks,
    ~ k

  2. Konstantin Kovshenin
    Member
    Posted 5 years ago #

    Resolved:

    $query = "SELECT guid, post_content, post_title FROM {$wpdb->posts} WHERE (post_status = 'attachment' || post_type = 'attachment') AND post_parent = '{$post->ID}'";
    $attachments = $wpdb->get_results($query);

Topic Closed

This topic has been closed to new replies.

About this Topic