Created
April 23, 2014 15:14
-
-
Save ivandoric/11219384 to your computer and use it in GitHub Desktop.
wordpress: Add custom field to gallery popup Wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* For adding custom field to gallery popup */ | |
function ime_autora_field($form_fields, $post) { | |
$form_fields["ime-autora"] = array( | |
"label" => __("Autor"), | |
"input" => "text", | |
"value" => get_post_meta($post->ID, "_ime-autora", true), | |
"helps" => __("Ime autora slike"), | |
); | |
return $form_fields; | |
} | |
// now attach our function to the hook | |
add_filter("attachment_fields_to_edit", "ime_autora_field", null, 2); | |
function ime_autora_field_save($post, $attachment) { | |
if( isset($attachment['ime-autora']) ){ | |
update_post_meta($post['ID'], '_ime-autora', $attachment['ime-autora']); | |
} | |
return $post; | |
} | |
add_filter("attachment_fields_to_save", "ime_autora_field_save", null , 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment