Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #7229
    Tamsin Carter
    Participant

    Hi. Excellent plugin and has been very useful but now we realise that where we have two versions of a file uploaded they both show the date added as the same date. One was added in July 2014 and one in June 2015 but they both show June 2015. In the media library you can see the real date added for the older file so the data is there but it is not being called in.

    Here is the page where two files are <http://modelcommerciallease.co.uk/leases/mcl-office-01/&gt; the lower file was added on 8th July 2014.

    How can I make the files show their correct added dates?

    Thanks

    Tamsin

    #7242
    Tamsin Carter
    Participant

    I am not sure how long you usually take to reply. I don’t mean to put pressure on but wondered if you can give me an idea as I have a client waiting. I think my client has already donated to the plugin – I certainly asked them to.

    Thank you.

    Tamsin

    #7259
    Bartosz
    Keymaster

    Can you do 2 tests on this:

    1) check what would you get with da_get_download_attachments( $post->ID ) – get all the attachments data for a post
    2) same with da_get_download_attachment( $attachment_id ) – get all data for a given attachment

    Will any of these functions get the correct date.

    #7263
    Tamsin Carter
    Participant

    Sorry I do not know where to put this code – I have tried a few things… can you help?

    #7264
    Bartosz
    Keymaster

    You should do that in a template file used to display the page you linked above. Don’t know which one it is in your theme – it’s theme specific.

    #7265
    Tamsin Carter
    Participant

    Do you mean in the theme’s functions.php file? If so should I just paste this code in there?

    #7266
    Tamsin Carter
    Participant

    I tried that but it didn’t work. I have tried putting it into the page in a code widget, two different ways: <modelcommerciallease.co.uk/leases/mcl-office-01/>

    #7268
    Tamsin Carter
    Participant

    I have added the code to the page template but it has not changed anything.

    I noticed that in the page under download attachments you can see the two attachments with their ‘date added’ info (which is wrong) then if you click the pencil to edit one of them it shows the title and correct date underneath. This seems to be the case with all the pages I have looked at. Though it is not always the case that the most recent date is used for previous attachments the dates are wrong and you can see the right ones when you go to edit or view the attachment info in wordpress.

    Thank you for looking at this.

    Tamsin

    #7269
    Tamsin Carter
    Participant

    With some help from a friend I used:
    <?php print_r(da_get_download_attachments( $post->ID )); ?>
    <?php print_r(da_get_download_attachment( $attachment_id )); ?>

    and this is the result:
    Array ( [765] => Array ( [attachment_id] => 765 [attachment_date] => 24 June 2015 06:18 [attachment_user_id] => 5 [attachment_exclude] => [attachment_user_name] => Michael Callaghan [attachment_downloads] => 48 [attachment_title] => MCL-OFFICE-01 [attachment_caption] => Version 1.1 [attachment_description] => Lease of the whole of an office building [attachment_size] => 124 kB [attachment_url] => http://modelcommerciallease.co.uk/wp-content/uploads/2015/06/MCL-OFFICE-01_V1-1.docx [attachment_type] => docx [attachment_icon_url] => http://modelcommerciallease.co.uk/wp-content/plugins/download-attachments/images/ext/unknown.gif ) [532] => Array ( [attachment_id] => 532 [attachment_date] => 24 June 2015 06:18 [attachment_user_id] => 5 [attachment_exclude] => [attachment_user_name] => Michael Callaghan [attachment_downloads] => 3086 [attachment_title] => MCL-OFFICE-01 [attachment_caption] => Version 1.0 [attachment_description] => Lease of whole building for office use [attachment_size] => 147 kB [attachment_url] => http://modelcommerciallease.co.uk/wp-content/uploads/2014/05/MCL-OFFICE-01.docx [attachment_type] => docx [attachment_icon_url] => http://modelcommerciallease.co.uk/wp-content/plugins/download-attachments/images/ext/unknown.gif ) )

    Both dates are the same and when you look at the files in wordpress you get different ones.

    Do you know why this is happening?

    Thanks

    Tamsin

    #7270
    Bartosz
    Keymaster

    Ok, can you post a screenshot of the file dates for these 2 files as you see this in the admin?

    #7272
    Tamsin Carter
    Participant

    Screenshot of the edit window for file 1

    Screenshot of the edit window for file 2

    Screenshot of the files in the edit page view - showing different dates

    #7273
    Bartosz
    Keymaster

    Ok, I see now. These are 2 different dates. The date that’s being displayed in DA metabox and on the frontend is the date the file was added to attachments to download for a given post.

    The date you’d like to get is the date the file was uploaded to WP media library.

    You’d have to use the following filter hook to modify that: da_get_download_attachments. It has a couple of attributes available: $files, $post_id, $args. You have to hook into that, generate a loop and modify “attachment_date” key for each of the attached files using WP get_the date function https://codex.wordpress.org/Function_Reference/get_the_date

    #7274
    Tamsin Carter
    Participant

    Thank you for your reply.

    I don’t think it can be the date it was attached to the page, as you can see the earlier document has been downloaded from there over 3000 times so it was not attached recently. If it is the attaching to the page date it must have been overwritten by some action?

    Is there any way to reset it or edit that date other than to use the upload date with the hook you mentioned?

    Thanks

    Tamsin

    #7276
    Bartosz
    Keymaster

    Maybe the file was reinserted or there’s a bug related to this – checking.

    You could modify that directly in the database ot use the filter hook – that’s what it is for.

    #7277
    Tamsin Carter
    Participant

    I am checking with the client if that file was reinserted. I will try to work out how to use the filter hook. Thank you.

    Tamsin

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.