0

I have a few pages in my wordpress website that I need to switch sometimes.

Precisely imagine a page that talks about Monday. The same page needs to talk about Tuesday just the day after.

The content is completely different from a day to another.

But it's the same page, with the same url, permalink whatever.

Now I use WP CLI.

You give a command like:

wp post update 1986 path

Where path is the path of the file that contains the html code that has to replace the existing one in page 1986.

So you have many files (one for Monday, one for Tuesday etc.) and every day you give the command above and your page gets replaced with the content from the file.

Is there a simpler way?

A plugin?

Do you know of any plugin that does this from the dashboard?

In my case it's not exactly predictable. So, I can't put it in crontab.

(Information about WP CLI: http://wp-cli.org/)

  • I'd suggest that the best way is to create a simple shortcode that grabs the current day. Then simply insert that shortcode on the page in place of the day text. Then every time the page is loaded the shortcode would insert the current day. – Phill Healey May 11 '17 at 16:57

1 Answers1

0

You can use this snippet to create a shortcode that displays the current day.

<?php function displaydate(){
return date('F jS, Y');
}
add_shortcode( 'date', 'displaydate' );

Then on your page, simply insert this shortcode [date] wherever you want the day to appear. You can tweak the output to your exact needs by editing the return date format.

Phill Healey
  • 3,084
  • 2
  • 33
  • 67
  • Maybe I didn't explain correctly. it's the entire content of the page that has to change. Monday's page is completely different from Tuesday's page and so on. It's not a matter of just showing the date. – Emanuele Santanche May 11 '17 at 17:57