WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Wordpress and I like to serve a page with a link to download. That link points to a new file EACH DAY. Is there a plugin that can do this?

  • Store a list of filename per day
  • Rotate each day using the right filename

If not, I can work around by using some kind of hashkey + yyyymmdd in the filename too. But don't know how. Any help? Thanks.

share|improve this question

migrated from stackoverflow.com Sep 29 '11 at 11:18

This question came from our site for professional and enthusiast programmers.

Your idea of using the current date in the filename would be the easiest. In the template for your page, you could have the following to generate your current day link:

<a href="/path/to/file/filename_<?php echo date('Y-m-d') ?>.pdf">Today's file</a>

The above uses the PHP date function to create a filename with the current date appended to it in this format:


So for today's date, the filename would be:


Update: Based on OP's comment, you could do the following:

  1. Create a shortcode. This would easily allow you to insert the PHP function call in any post you wanted to create the "Today's file" link in.
  2. In the shortcode, use the PHP hash function to take today's date and generate a hash value.
  3. You would then need to have the files on the server with an equivalent hash value in their file name for each day.


In your theme's functions.php file, you would define the following:

// Define the function that the [todays-file] shortcode wil invoke
// Purpose is to return the link with the hashed file name
function todays_file_func($atts) {

    // Generate the hash of today's date
    $salt = "A random string to make it harder to crack the hash";
    $dateHash = hash('md5', date('Y-m-d').$salt);

    // Output the link with today's filename
    return "<a href='/path/to/filename_".$dateHash.".pdf'>Today's file</a>";
add_shortcode( 'todays-file', 'todays_file_func' );

Then you just need to add the shortcode to any post:

share|improve this answer
Yeah but I don't want people who download can guess the filename format and download the next day files. I guess I can use hashkey with some formula using timestamp. However, how do I insert php code within the post itself?? – HP. Sep 28 '11 at 23:30
Added an update with answers to your comment questions. – Pat Sep 29 '11 at 0:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.