Published on Jul 20, 2018

[Video] Dynamic year in Oxygen

Sridhar Katakam

Footer text in websites typically have the current year text.

Let’s see how this can be made dynamic i.e., automatically showing the current year in Oxygen.

Step 1

Install and activate Code Snippets plugin if you have not already.

Step 2

Add a new Snippet with a title of say “Current year” having the following code:

function sk_current_year() {
echo date( 'Y' );
}

You can leave sk_current_year as is or replace it with your desired function name (make sure it does not contain spaces or hyphens).

Step 3

In the Oxygen editor place the cursor wherever you want the current year to appear, then click on Insert Data, then PHP Function Return Value and paste sk_current_year (i.e., the name of the function we created in the earlier step) in the Function Name field and Insert.

The value may not appear in the editor but should work on the frontend.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-ocalendar-check-omagnifiercrossmenuchevron-downarrow-right