Retrieving a custom link on an attachment

On the Trac ticket you’ve linked at the bottom there is a solution to make it work function _save_attachment_url($post, $attachment) { if ( isset($attachment[‘url’]) ) update_post_meta( $post[‘ID’], ‘_wp_attachment_url’, esc_url_raw($attachment[‘url’]) ); return $post; } add_filter(‘attachment_fields_to_save’, ‘_save_attachment_url’, 10, 2); function _replace_attachment_url($form_fields, $post) { if ( isset($form_fields[‘url’][‘html’]) ) { $url = get_post_meta( $post->ID, ‘_wp_attachment_url’, true ); if ( … Read more

How to add media from front-end to an existing post?

@AboSami actually answered this question in an older post that was not showing up in my search diligence. While he was actually looking for something else his example code worked great. Here’s the script: <?php $post_id = $post->ID; if ( isset( $_POST[‘html-upload’] ) && !empty( $_FILES ) ) { require_once(ABSPATH . ‘wp-admin/includes/admin.php’); $id = media_handle_upload(‘async-upload’, … Read more

Show Post ID in “Find Posts or Pages” box in Media Library?

You cannot do that with pure PHP. The table is created in wp-admin/includes/ajax-actions.php::wp_ajax_find_posts(), and there is no filter. But look at the radio buttons: name=”found_post_id” value=”‘ . esc_attr($post->ID) You can print a script on the action admin_footer-upload.php that extracts the post ID from the values and adds a new column to the table. Here is … Read more

Insert Media – Attachment – Link to : Remove the “attachment page” option

These options are hardcoded into the tmpl-attachment-display-settings Underscore media template in the /wp-includes/media-template file: <script type=”text/html” id=”tmpl-attachment-display-settings”> <h3><?php _e(‘Attachment Display Settings’); ?></h3> …cut… <select class=”link-to” data-setting=”link” <# if ( data.userSettings && ! data.model.canEmbed ) { #> data-user-setting=”urlbutton” <# } #>> <# if ( data.model.canEmbed ) { #> <option value=”embed” selected> <?php esc_attr_e(‘Embed Media Player’); ?> … Read more

custom fields for attachments?

Here is a tutorial that shows how to add custom fields to the attachments/media gallery/thickbox/iframe/whatever-you-call it overlay. I’ve successfully used it, but have not yet taken it much further by adding radio buttons/checkboxes/etc or messed with limiting the changes to particular post types, but that all looks completely doable too. Here is the code from … Read more

Give attachments an archive page

This is untested, so apologies there, but I’m thinking out loud, have you tried re-registering the post type afterwards? Or flushed rewrite rules after your initial attempt with flush_rewrite_rules();? function change_attachment_post_type() { $args = get_post_type_object(‘attachment’); $args->has_archive = true; $args->rewrite = [ ‘slug’ => ‘media’ ]; register_post_type($args->name, $args); // As a temporary one time, remove after … Read more

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