HTML code in Custom field

UPDATED ANSWER The correct function to use in context to WordPress and its intended API for this purpose is; esc_textarea Thus your code would reflect something like this; <textarea><?php echo esc_textarea($images);?></textarea> Although htmlspecialchars and htmlentities are valid to use, and even though esc_textarea wraps htmlspecialchars anyway, its more appropriate to use the official API call. … Read more

Add custom field to image editor

To add a custom field to attachments, place the following code in your functions.php. add_filter(‘attachment_fields_to_edit’, ‘edit_media_custom_field’, 11, 2 ); add_filter(‘attachment_fields_to_save’, ‘save_media_custom_field’, 11, 2 ); function edit_media_custom_field( $form_fields, $post ) { $form_fields[‘custom_field’] = array( ‘label’ => ‘Custom Field’, ‘input’ => ‘text’, ‘value’ => get_post_meta( $post->ID, ‘_custom_field’, true ) ); return $form_fields; } function save_media_custom_field( $post, $attachment … Read more

Custom field being erased after autosave

I use the following code to prevent updates of my custom fields during auto-saves, ajax requests (quick edit) and bulk edits. add_action(‘save_post’, ‘save_my_post’); function save_my_post($post_id) { // Stop WP from clearing custom fields on autosave, // and also during ajax requests (e.g. quick edit) and bulk edits. if ((defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) || (defined(‘DOING_AJAX’) && DOING_AJAX) … Read more

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