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

  • Use Markdown, and it will escape the code for you, like `<div class="cool">`.
  • Use triple-backticks for blocks of code.
    ``` 
    	<div>multi-line block of code</div>
    ```
  • Otherwise, escape your code, like <code>&lt;div class="cool"&gt;</code>. Markdown is just easier though.

Current ye@r *

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