Saving Custom Field in Attachment Window in WordPress 3.5

I wanted to be able to add author information to my attachments and merged this code: http://www.billerickson.net/wordpress-add-custom-fields-media-gallery/ with the one you refer to. I Got it to work fully in the modal window via AJAX. The modified code is as follows: /** * Add Author Name and URL fields to media uploader * * @param … Read more

Associate an existing image with a post

You can modify an existing media library image using wp_insert_attachment by setting the ID key in the parameter array. $attachment = array( ‘ID’ => $existing_library_attachment_id, ‘post_parent’ => $custom_post_id ); wp_insert_attachment( $attachment ); This will update the attachment post with ID $existing_library_attachment_id to have a post_parent value of $custom_post_id. However, the only thing this will affect … Read more

Post being redirected to attachment post

I think the reason for this is the get_page_by_path() check inside the WP_Query, because it’s checking for both page and attachment slugs, in this case. So if we have both an attachment and a post with the someslug postname and visit: example.tdl/someslug then get_page_by_path() will generate the following query: SELECT ID, post_name, post_parent, post_type FROM … 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

Get attachment ID of author_meta image – Attachment Metadata

I suggest you to use the more newer media manager dialog; WordPress will hanlde all the image upload stuff, including generating intermediate sizes and attachement metadata. Here a working example (it is a quick example built from a previous code, it may needs some tweaks to be used on production): add_action( ‘admin_enqueue_scripts’, ‘load_wp_media_files’ ); function … 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

Get post id by attachment id?

get_post_ancestors can give you the ID of the object an attachment is associated with: $attachment_id = 42; $parent = get_post_ancestors( $attachment_id ); echo $parent[0]; // $parent will be an array

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