can you set a default value to a custom field

You can check it by adding a hook to save_post action. In this way all your posts will have default value for a custom field. add_action( ‘save_post’, ‘wpse8170_save_post’, 10, 2 ); function wpse8170_save_post( $post_id, WP_Post $post ) { if ( ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) || !current_user_can( ‘edit_post’ ) ) { return; } … 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

Display thumbnail from custom field

can you explain why do you need custom fields ? (personally i think they are HUGELY over-used.. especially for images ) if there is no specific reason why you need it , you could use the the_post_thumbnail(); function . like so : the_post_thumbnail(‘thumbnail’); // Thumbnail (default 150px x 150px max) the_post_thumbnail(‘medium’); // Medium resolution (default … Read more