Plugins and shortcodes can extend WordPress’s power markedly. Tons of free, pre-written ones are available at https://wordpress.org/plugins/. The header there says “Browse 60,453 free plugins” which means most every topic is covered, probably many times over.
What if you want to do your own plugins? It turns out that isn’t very difficult and there are many resources to help both getting started and with on-going development activities. Here are a few resources I started with. Note that many of these give code examples which I find very useful for learning anything new.
- WordPress Shortcodes: Ultimate Guide on How to Create and Use Them – excellent starting article. Very simple, step by step discussion and examples.
- How to Create a Custom WordPress Plugin From Scratch – another good article with fairly complex code examples
- Creating A WordPress Plugin Is Easier Than You Think | Beaver Builder – 5 steps to a plugin. Simple overview and example. Pointers to key API and WP Functions references in CODEX
- Introduction to Plugin Development – a WordPress Developer Handbook focused on plugin development.
- WordPress hooks database – action and filter hooks for wp plugin developers — Adam Brown, BYU Political Science
Some Examples
I followed the first reference to generate a shortcode for the current year, which is 2025 and then branched off from there to generate another for the current date and time: 10 Dec 2025 3:52 UTC. The highlighted items are the results of the shortcodes. Neither of these took any input, but merely returned the appropriate values when invoked.
Current Year:
<?php
/*
Plugin Name: Salcodes
Version: 1.0
Description: Output the current year in your WordPress site.
Author: Salman Ravoof
Author URI: https://www.salmanravoof.com/
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: salcodes
*/
/**
* [current_year] returns the Current Year as a 4-digit string.
* @return string Current Year
*/
add_shortcode( 'current_year', 'salcodes_year' );
function salcodes_init($atts){
function salcodes_year() {
return getdate()['year'];
//return "ollie";
}
}
add_action('init', 'salcodes_init');
/** Always end your PHP files with this closing tag */
?>
Date-Time Display
<?php
/*
Plugin Name: date-time-display
Description: Displays the date and time of day.
Version: 1.0.1
Author: owa
License: GPL2
*/
/*
* Shortcode is [date_time_display]
* returns date string formatted like 17 Feb 2023 14:26 UTC
* Prefix is dtd
*/
function date_time_display($atts) {
// format date as 17 Feb 2023 14:26 UTC
$current_date_time = date('d M Y G:i e');
//then output it
return $current_date_time;
}
function dtd_shortcodes_init(){
add_shortcode('date_time_display', 'date_time_display');
}
add_action('init', 'dtd_shortcodes_init');
?>
User IP and Location
On a closing note, here is a plugin available at the WordPress site here that generates information about the current user. See an example of some of its features in the footer, below.
