Support » Plugins » Modify date of attachments

  • Resolved herrvollbaer



    Does anyone know a good way to modify the date of attachments. It’s possible by hacking the database or by changing the post type of an attachment to post, but that is not an elegant method.

    I been looking for a plugin that could do the job, but without luck…


Viewing 4 replies - 1 through 4 (of 4 total)
  • It always helps to know why someone want so do something, so why do you need to do this?

    Not to be a pain… this may be simple or it may be hard. It depends on context.

    I created a simple portfolio theme that displays all image attachments in the database ordered by date ( I want to be able to change the date and therefore the order of the images.

    I think something like this is what you are going to need.

    Plugin To Add Custom Field To An Attachment In WordPress

    Hi s_ha_dum!

    Many thanks for the link, it really helped me. To add an edit box that let’s you edit the date of an attachment only a few lines of code are needed in the themes function.php:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    // Set attachment post date:
    // Add a custom field to an attachment in WordPress
    function hv_attachment_fields_edit($form_fields, $post) {
        $form_fields['post_date']['label'] = 'Date';
        $form_fields['post_date']['value'] = $post->post_date;
        $form_fields['post_date']['helps'] = 'Set the post date';
        return $form_fields;
    // save custom field to post_meta
    function hv_attachment_fields_save($post, $attachment) {
    	$post['post_date'] = $attachment['post_date'];
        return $post;
    add_filter( 'attachment_fields_to_edit', 'hv_attachment_fields_edit', 10, 2);
    add_filter( 'attachment_fields_to_save', 'hv_attachment_fields_save', 10, 2);
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Modify date of attachments’ is closed to new replies.