WP Tavern Forums Blocks Showcase How I updated my footer copyright year automatically

How I updated my footer copyright year automatically

  • Author
    • Marcio DuarteMarcio Duarte

      One day, I was looking for a way to dynamically add the current year to the copyright statement in the footer of my website. You know, so that I wouldn’t have to manually edit it every New Year’s Eve. But I only found shortcodes for that.

      There probably was already a block to do that somewhere, but I also wanted to use this as an opportunity to develop a custom block from scratch. I ended up creating a simple block plugin that does just that: it inserts the current year.

      I’m a firm believer in modularity when we’re talking about blocks. There are lots of block libraries out there, but the problem with this approach is that if you need just one function, you end up including a lot of unused code in your WordPress instance.

      You can find the block plugin here:

      This will probably be integrated into the WordPress core sometime in the future, but for now, it’s a refreshingly simple way to solve this issue. Not to mention that it opened up a whole new horizon for me in relation to block development. Enjoy.

    • niall_flynnniall_flynn
      $year = date("y");
      echo $year;

      Create a short code with that in it, call it [copy-year] add it to the block/classic editor/builder. It should say year started too so 2000-2023 or your saying it’s been copyrighted this year. Easiest fix is not to include the year.

    • Marcio DuarteMarcio Duarte

      I know, but shortcodes were exactly what I was trying to avoid.

    • niall_flynnniall_flynn

      Plugin is block and shortcode, so has both.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.