How to Filter in the “Add Media Popup” to show only “unattached” Media

Can’t deliver a working example but there is this relevant section in wp-includes/js/media-views.js on Line 3173: media.view.AttachmentFilters.Uploaded = media.view.AttachmentFilters.extend({ createFilters: function() { var type = this.model.get(‘type’), types = media.view.settings.mimeTypes, text; if ( types && type ) text = types[ type ]; this.filters = { all: { text: text || l10n.allMediaItems, props: { uploadedTo: null, orderby: … Read more

Metabox with file upload to custom directory

I will not follow the whole metabox thing, but Just to point some ” leads ” as you asked regarding the upload folder .. The upload dir in wordpress is set via the wp_upload_dir() function – which is filterable .. $uploads = apply_filters( ‘upload_dir’, array( ‘path’ => $dir, ‘url’ => $url, ‘subdir’ => $subdir, ‘basedir’ … Read more

Producing a list of media library items categorized under a certain taxonomy item

You can use a tax query for all “Reference Type” terms, which will retrieve all attachments that have at least one “Reference Type” term. $rt_media = new WP_Query( array( ‘posts_per_page’ => -1, ‘post_type’ => ‘attachment’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘reference_type’, ‘terms’ => get_terms( ‘reference_type’, array( ‘hide_empty’ => false, ‘fields’ => ‘ids’, ) ) … Read more

Assign one featured image to multiple posts?

I’d suggest you check the $featuredimg URL. If there is already an attachment with this URL just get the ID and call update_post_meta( $pid, ‘_thumbnail_id’, $thumb_id ); There’s a useful function to get the ID for an existing URL: Philip Newcomer function pn_get_attachment_id_from_url( $attachment_url=”” ) { global $wpdb; $attachment_id = false; // If there is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)