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```. You don't need to escape code in backticks, Markdown does that for you.

Sadly, it's kind of broken. WordPress only accepts a subset of HTML in comments, which makes sense, because certainly some HTML can't be allowed, like <script> tags. But this stripping happens before the comment is processed by Markdown (via Jetpack). It seems to me that would be reversed, because after Markdown processes code in backticks, it's escaped, thus safe. If you think you can fix this issue, get in touch!

If you need to make sure the code (typically HTML) you post absolutely posts correctly, escape it and put it within <pre><code> tags.

Current ye@r *

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