Grow your CSS skills. Land your dream job.

Last updated on:

Year Shortcode

For the functions.php file:

function year_shortcode() {
  $year = date('Y');
  return $year;
}
add_shortcode('year', 'year_shortcode');

Usage

Use [year] in your posts.

Comments

  1. J. DeForest

    Thanks! That code works great!!!

  2. Jamaima
    Permalink to comment#

    Nice, works like a charm. Thanks for sharing this useful tip.

  3. Permalink to comment#

    Copyright © $starty){echo $starty.’-‘.$nowy;}else{echo $nowy;} }else{ echo date(“Y”);} ?> . All Rights Reserved.

  4. Permalink to comment#

    Copyright © <?php date_default_timezone_set(PRC); $starty=get_option(‘cwpcg_starty’);
    $nowy=date(“Y”); if(get_option(‘cwpcg_starty’)){ if($nowy>$starty){echo $starty.’-‘.$nowy;}else{echo $nowy;} }else{ echo date(“Y”);} ? > <?php bloginfo(‘name’); ? >. All Rights Reserved.

Leave a Comment

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like this:

```
<div>Example code</div>
```

You don't need to escape code in backticks, Markdown does that for you. If anything screws up, contact us and we can fix it up for you.

*May or may not contain any actual "CSS" or "Tricks".