Extra Shortcodes Shortcodes

Below, you’ll find a detailed guide on how to add the Extra Shortcodes Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Extra Shortcodes Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Extra Shortcodes Plugin and the shortcodes it provides:

Plugin Icon
Extra Shortcodes

"Extra Shortcodes is a versatile WordPress plugin designed to add functionality to your site. It offers additional, customizable shortcodes for enhancing your website's features and design."

★★★★✩ (10) Active Installs: 2000+ Tested with: 6.2.3 PHP Version: false
Included Shortcodes:
  • [extra_archives]
  • [extra_taxonomies]
  • [bloginfo]
  • [site_name]
  • [site_desc]
  • [site_url]
  • [wp_version]
  • [date]
  • [date_i18n]
  • [time]
  • [year]
  • [month]
  • [month_name]
  • [day]
  • [weekday]
  • [hours]
  • [minutes]
  • [seconds]

Extra Shortcodes [extra_archives] Shortcode

The Extra Shortcodes plugin’s ‘extra_archives’ shortcode allows you to display a list of your site’s archives. It offers customization options for the type of archives, limit, and order.

Shortcode: [extra_archives]

Parameters

Here is a list of all possible extra_archives shortcode parameters and attributes:

  • type – Determines the period for the archives (e.g., ‘monthly’, ‘yearly’).
  • limit – Sets the maximum number of archives to display.
  • show_post_count – Displays the number of posts for each archive when set to 1.
  • order – Sets the order of the archives (e.g., ‘ASC’ for ascending, ‘DESC’ for descending).

Examples and Usage

Basic example – The shortcode displays a monthly archive list without post count.

[extra_archives type="monthly" show_post_count=0 /]

Advanced examples

Display a yearly archive list with a limit of 5 years, ordered in ascending order.

[extra_archives type="yearly" limit="5" order="ASC" /]

Show a daily archive list, displaying the post count, and limiting the list to the last 10 days.

[extra_archives type="daily" show_post_count=1 limit="10" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [extra_archives] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'extra_archives', array( __CLASS__, 'archives_shortcode' ) );

Shortcode PHP function:

function archives_shortcode( $atts ) {
		$defaults = array(
			'type' => 'monthly',
			'limit' => '',
			//'format' => 'html',
			//'before' => '',
			//'after' => '',
			'show_post_count' => 0,
			//'echo' => 0,
			'order' => 'DESC'
		);
		extract( shortcode_atts( $defaults, $atts ) );
		$archives_args = array(
			'type' => $type,
			'limit' => $limit,
			'format' => 'html',
			'before' => '',
			'after' => '',
			'show_post_count' => $show_post_count,
			'echo' => 0,
			'order' => $order
		);

		return '<ul>'."\n".wp_get_archives( $archives_args ).'</ul>'."\n".'<!-- Powered by Extra Shortcodes wordpress.org/plugins/extra-shortcodes/ -->';
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [extra_taxonomies] Shortcode

The Extra Shortcodes plugin’s ‘extra_taxonomies’ shortcode is designed to list categories in a WordPress site. It allows customization of category lists based on various parameters like order, style, count, and taxonomy.

Shortcode: [extra_taxonomies]

Parameters

Here is a list of all possible extra_taxonomies shortcode parameters and attributes:

  • orderby – Determines the sorting method for categories.
  • order – Sets the order direction (ascending or descending).
  • show_count – Displays or hides the number of posts in each category.
  • hide_empty – Hides categories without any posts.
  • use_desc_for_title – Uses the category description as the title attribute.
  • child_of – Shows only the children of a specific category.
  • exclude – Excludes specified categories from the list.
  • exclude_tree – Excludes a category and its descendants.
  • include – Includes only certain categories.
  • hierarchical – Arranges categories hierarchically or flatly.
  • number – Limits the number of categories displayed.
  • depth – Sets the number of levels in the hierarchy of categories.
  • taxonomy – Specifies the taxonomy to be displayed.

Examples and Usage

Basic example – Displays a list of categories, ordered by name in ascending order, with the count of posts in each category, and excludes any categories that are empty.

[extra_taxonomies orderby="name" order="ASC" show_count="1" hide_empty="1" /]

Advanced examples

Displays a list of categories, ordered by name in descending order, without the count of posts in each category, includes all categories even if they are empty, and includes only the top-level categories (depth=1).

[extra_taxonomies orderby="name" order="DESC" show_count="0" hide_empty="0" depth="1" /]

Displays a list of categories, ordered by ID in ascending order, with the count of posts in each category, excludes any categories that are empty, and excludes specific categories by their IDs (exclude=’3,7,31′).

[extra_taxonomies orderby="ID" order="ASC" show_count="1" hide_empty="1" exclude='3,7,31' /]

Displays a list of post tags instead of categories (taxonomy=’post_tag’), ordered by name in ascending order, with the count of posts in each tag, and excludes any tags that are empty.

[extra_taxonomies taxonomy='post_tag' orderby="name" order="ASC" show_count="1" hide_empty="1" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [extra_taxonomies] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'extra_taxonomies', array( __CLASS__, 'taxonomies_shortcode' ) );

Shortcode PHP function:

function taxonomies_shortcode( $atts ) {
		$defaults = array(
			//'show_option_all' => '',
			'orderby' => 'name',
			'order' => 'ASC',
			//'style' => 'list',
			'show_count' => 0,
			'hide_empty' => 1,
			'use_desc_for_title' => 1,
			'child_of' => 0,
			'exclude' => '',
			'exclude_tree' => '',
			'include' => '',
			'hierarchical' => 1,
			//'title_li' => '',
			'number' => null,
			//'echo' => 0,
			'depth' => 0,
			'taxonomy' => 'category',
		);
		extract( shortcode_atts( $defaults, $atts ) );
		$categories_args = array(
			'show_option_all' => '',
			'orderby' => $orderby,
			'order' => $order,
			'style' => 'list',
			'show_count' => $show_count,
			'hide_empty' => $hide_empty,
			'use_desc_for_title' => $use_desc_for_title,
			'child_of' => $child_of,
			'exclude' => $exclude,
			'exclude_tree' => $exclude_tree,
			'include' => $include,
			'hierarchical' => $hierarchical,
			'title_li' => '',
			'number' => $number,
			'echo' => 0,
			'depth' => $depth,
			'taxonomy' => $taxonomy,
		);

		return '<ul>'."\n".wp_list_categories( $categories_args ).'</ul>'."\n".'<!-- Powered by Extra Shortcodes wordpress.org/plugins/extra-shortcodes/ -->';
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [bloginfo] Shortcode

The ‘bloginfo’ shortcode fetches blog information as per the attribute specified. It defaults to the blog name if no attribute is provided.

Shortcode: [bloginfo]

Parameters

Here is a list of all possible bloginfo shortcode parameters and attributes:

  • show – specifies the type of blog information to display

Examples and Usage

Basic example – Show the name of the blog using the bloginfo shortcode

[bloginfo show="name" /]

Advanced examples

Display the blog’s description using the bloginfo shortcode. If the description is not set, it will default to showing the blog’s name.

[bloginfo show="description" /]

Display the blog’s URL using the bloginfo shortcode. This can be useful for creating absolute links to your blog from within your posts or pages.

[bloginfo show="url" /]

Display the blog’s WordPress version using the bloginfo shortcode. This can be useful for troubleshooting or for displaying your WordPress version for transparency.

[bloginfo show="version" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [bloginfo] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'bloginfo', array( __CLASS__, 'bloginfo_shortcode' ) );

Shortcode PHP function:

function bloginfo_shortcode( $atts ) {
		extract(shortcode_atts(array(
			'show' => 'name'
		), $atts));
		return get_bloginfo($show);
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [site_name] Shortcode

The ‘site_name’ shortcode from the extra-shortcodes plugin fetches the name of your WordPress site. It uses the ‘get_bloginfo’ function to retrieve this information.

Shortcode: [site_name]

Examples and Usage

Basic example – A simple way to use the shortcode to display the name of the site.

[site_name /]

Advanced examples

Incorporating the shortcode within a sentence to create a more personalized message that includes the site name.

Welcome to [site_name /], we're glad to have you here!

Combining the site name shortcode with other shortcodes to display a more complex piece of content. In this case, we’re using a fictional ‘current_year’ shortcode together with our ‘site_name’ shortcode to display a copyright statement.

Copyright [current_year /] by [site_name /]. All rights reserved.

Please note that the ‘site_name’ shortcode does not accept any parameters or attributes, as it simply returns the name of the site as defined in the site settings.

PHP Function Code

In case you have difficulties debugging what causing issues with [site_name] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'site_name', array( __CLASS__, 'site_name_shortcode' ) );

Shortcode PHP function:

function site_name_shortcode() {
		return get_bloginfo('name');
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [site_desc] Shortcode

The ‘site_desc’ shortcode is a part of the extra-shortcodes plugin. It’s designed to fetch and return the description of your WordPress site.

Shortcode: [site_desc]

Examples and Usage

Basic example – The shortcode [site_desc] displays the description of the site as defined in the site settings.

[site_desc /]

Advanced examples

There are no additional parameters available for this shortcode. This is because the function ‘get_bloginfo’ only retrieves the site description, and does not accept any additional parameters. Therefore, the usage of this shortcode is straightforward and does not include any variations.

However, if you want to include the site description within a larger block of text or HTML, you can do so. Here’s an example:

Welcome to our website, [site_desc]. We hope you find what you're looking for.

In this example, the shortcode [site_desc] will be replaced by the site description wherever it is placed within the text.

PHP Function Code

In case you have difficulties debugging what causing issues with [site_desc] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'site_desc', array( __CLASS__, 'site_desc_shortcode' ) );

Shortcode PHP function:

function site_desc_shortcode() {
		return get_bloginfo('description');
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [site_url] Shortcode

The Extra-Shortcodes Plugin’s ‘site_url’ shortcode is a handy tool that returns the URL of your website. It simplifies the process of retrieving your site’s URL.

Shortcode: [site_url]

Examples and Usage

Basic example – The given shortcode is used to display the site URL of the current WordPress site.

[site_url /]

Advanced examples

While the given shortcode does not inherently support additional parameters, you can modify the PHP function to accept and utilize attributes. The following examples will illustrate this concept.

Modifying the function to accept a ‘type’ attribute, which can be used to display different types of site information depending on its value.

“`php
function site_url_shortcode($atts) {
$atts = shortcode_atts(
array(
‘type’ => ‘url’, // default value
), $atts, ‘site_url’ );

return get_bloginfo($atts[‘type’]);
}
“`

With the above modification, you can now use the ‘type’ attribute in the shortcode to display different types of site information. The following example will display the site description:

[site_url type='description' /]

Similarly, you can display the site name:

[site_url type='name' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [site_url] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'site_url', array( __CLASS__, 'site_url_shortcode' ) );

Shortcode PHP function:

function site_url_shortcode() {
		return get_bloginfo('url');
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [wp_version] Shortcode

The WP_Version shortcode is a handy tool within the Extra-Shortcodes plugin. It retrieves and displays the current WordPress version of your site.

Shortcode: [wp_version]

Examples and Usage

Basic example – Displays the WordPress version of your website using the ‘wp_version’ shortcode.

[wp_version /]

Advanced examples

While the ‘wp_version’ shortcode does not accept any parameters, you can combine it with other shortcodes or functions to create more complex outputs. Here are a few examples:

Display the WordPress version along with a custom message:

Running on WordPress version: [wp_version /]

Use it within a conditional statement in a shortcode that accepts parameters:

[if_wp_version version="5.0"]You are running WordPress 5.0 or higher![/if_wp_version]

Please note that the above examples require additional plugins or custom code to work.

PHP Function Code

In case you have difficulties debugging what causing issues with [wp_version] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wp_version', array( __CLASS__, 'wp_version_shortcode' ) );

Shortcode PHP function:

function wp_version_shortcode() {
		return get_bloginfo('version');
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [date] Shortcode

The Extra-Shortcodes plugin ‘date’ shortcode is designed to display the current date on your WordPress site. This shortcode accepts three parameters: ‘format’, ‘timestamp’, and ‘use_wordpress_timezone’. The ‘format’ parameter defines the date format, ‘timestamp’ sets the specific time, and ‘use_wordpress_timezone’ allows using WordPress’s default timezone.

Shortcode: [date]

Parameters

Here is a list of all possible date shortcode parameters and attributes:

  • format – defines the format how date will be displayed
  • timestamp – sets the specific time to display
  • use_wordpress_timezone – if set to 1, uses the WordPress defined timezone

Examples and Usage

Basic example – A simple use of the date shortcode to display the current date with the default format.

[date /]

Advanced examples

Displaying a specific date with a custom format. The format ‘Y-m-d’ will display the date in the format ‘Year-Month-Day’.

[date format="Y-m-d" timestamp="2022-12-31" /]

Using the shortcode to display the current date with a custom format and the WordPress timezone. This will display the date according to the timezone set in the WordPress settings.

[date format="l jS \of F Y h:i:s A" use_wordpress_timezone="1" /]

Displaying a specific date with a custom format and the GMT offset. The timestamp ‘2022-12-31 15:30:00’ is in GMT and will be converted to the WordPress timezone.

[date format="Y-m-d H:i:s" timestamp="2022-12-31 15:30:00" use_wordpress_timezone="1" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [date] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'date', array( __CLASS__, 'date_shortcode' ) );

Shortcode PHP function:

function date_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'format' => 'l jS \of F Y',
			'timestamp' => 'now',
			'use_wordpress_timezone' => '0'
		), $atts ) );
		if ( $use_wordpress_timezone == 1 OR $use_wordpress_timezone == '1' OR $use_wordpress_timezone == true OR $use_wordpress_timezone == 'true' ) {
			//$date = get_gmt_from_date();
			if ( get_option( 'timezone_string' ) AND get_option( 'timezone_string' ) != '' ) {
				date_default_timezone_set( get_option( 'timezone_string' ) );
				$date = date( $format, strtotime( $timestamp ) );
				date_default_timezone_set(@date_default_timezone_get()); // set default timezone
			} elseif ( get_option( 'gmt_offset' ) AND get_option( 'gmt_offset' ) != '' ) {
				$date = date( $format, strtotime( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS.' seconds' ) ) . get_option( 'gmt_offset' );
			} else {
				$date = date( $format, strtotime( $timestamp ) );
			}
		} else {
			$date = date( $format, strtotime( $timestamp ) );
		}

		return $date;
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [date_i18n] Shortcode

The ‘date_i18n’ shortcode from the Extra Shortcodes plugin is designed to display the date in a specified format. This shortcode takes two parameters: ‘format’ and ‘timestamp’. ‘Format’ defines the date’s presentation, while ‘timestamp’ specifies the date to display. If no timestamp is given, it defaults to ‘now’.

Shortcode: [date_i18n]

Parameters

Here is a list of all possible date_i18n shortcode parameters and attributes:

  • format – Defines the date format to be displayed
  • timestamp – Specifies the time for the date function

Examples and Usage

Basic example – A simple usage of the date_i18n shortcode to display the current date in a standard format.

[date_i18n]

Advanced examples

Displaying the date in a specific format. Here, ‘l, F j, Y’ will output the full name of the day of the week, the full name of the month, the day of the month, and the full year.

[date_i18n format='l, F j, Y']

Displaying a specific timestamp. The timestamp ‘2022-12-31 23:59:59’ is converted to Unix timestamp using strtotime before being passed to date_i18n.

[date_i18n timestamp='2022-12-31 23:59:59']

Displaying a specific timestamp in a specific format. Here, ‘Y-m-d H:i:s’ will output the date in the format ‘Year-Month-Day Hour:Minute:Second’.

[date_i18n format='Y-m-d H:i:s' timestamp='2022-12-31 23:59:59']

PHP Function Code

In case you have difficulties debugging what causing issues with [date_i18n] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'date_i18n', array( __CLASS__, 'date_i18n_shortcode' ) );

Shortcode PHP function:

function date_i18n_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'format' => 'l jS \of F Y',
			'timestamp' => 'now'
		), $atts ) );
		return date_i18n( $format, strtotime( $timestamp ) );
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [time] Shortcode

The Extra-Shortcodes plugin’s ‘time’ shortcode allows you to display the current time on your WordPress site. This shortcode is customizable, enabling you to set the time format and timestamp. The PHP code for this shortcode extracts attributes for format and timestamp. The default format is ‘h:i:s A’, displaying the time in a 12-hour format with AM/PM. The default timestamp is ‘now’, which shows the current time. The ‘time’ shortcode is a handy tool for real-time updates on your site.

Shortcode: [time]

Parameters

Here is a list of all possible time shortcode parameters and attributes:

  • format – specifies the format of the displayed time
  • timestamp – sets the specific time to display

Examples and Usage

Basic example – The following shortcode displays the current time with the default format ‘h:i:s A’.

[time /]

Advanced examples

Displaying the current time in a different format. The ‘format’ attribute allows you to specify the time format. In the following example, the time format is set to ‘H:i’ which displays the time in 24-hour format without seconds.

[time format='H:i' /]

Displaying a specific timestamp. The ‘timestamp’ attribute allows you to specify a particular timestamp to display. In the following example, the timestamp is set to ‘2022-12-31 23:59:59’. The time will be displayed in the default format ‘h:i:s A’.

[time timestamp='2022-12-31 23:59:59' /]

Displaying a specific timestamp in a different format. In the following example, the timestamp is set to ‘2022-12-31 23:59:59’ and the time format is set to ‘H:i’.

[time format='H:i' timestamp='2022-12-31 23:59:59' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [time] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'time', array( __CLASS__, 'time_shortcode' ) );

Shortcode PHP function:

function time_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'format' => 'h:i:s A',
			'timestamp' => 'now'
		), $atts ) );
		return date( $format, strtotime( $timestamp ) );
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [year] Shortcode

The Extra-Shortcodes plugin’s ‘year’ shortcode is a versatile tool for displaying years. It allows users to manipulate time by adding or subtracting years from the current year. The ‘year’ shortcode accepts three parameters: ‘plus’, ‘minus’, and ‘timestamp’. If ‘plus’ is set, it adds that many years to the current year. If ‘minus’ is set, it subtracts that many years. If neither is set, it defaults to the current year. Shortcode: [year plus=”2″] The ‘timestamp’ parameter allows users to specify a different starting point. By default, it is set to ‘now’, but it can be any valid timestamp. Shortcode: [year timestamp=”2022-01-01″]

Shortcode: [year]

Parameters

Here is a list of all possible year shortcode parameters and attributes:

  • plus – adds specified number of years to the current year
  • minus – subtracts specified number of years from the current year
  • timestamp – sets the year to the one specified in the timestamp

Examples and Usage

Basic example – Display the current year using the shortcode without any parameters.

[year /]

Advanced examples

Display the year after 2 years from now. This uses the ‘plus’ attribute and sets it to 2.

[year plus=2 /]

Display the year 3 years ago. This uses the ‘minus’ attribute and sets it to 3.

[year minus=3 /]

Display the year of a specific timestamp. This uses the ‘timestamp’ attribute and sets it to a specific date.

[year timestamp="2022-12-31" /]

Display the year after 1 year from a specific timestamp. This uses both ‘plus’ and ‘timestamp’ attributes. The ‘plus’ attribute is set to 1 and the ‘timestamp’ attribute is set to a specific date.

[year plus=1 timestamp="2022-12-31" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [year] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'year', array( __CLASS__, 'year_shortcode' ) );

Shortcode PHP function:

function year_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'plus' => 0,
			'minus' => 0,
			'timestamp' => 'now'
		), $atts ) );
		if ( !empty( $plus ) ) {
			$year = date( 'Y', strtotime( '+'.intval($plus).' years' ) );
		} elseif ( !empty( $minus ) ) {
			$year = date( 'Y', strtotime( '-'.intval($minus).' years' ) );
		} else {
			$year = date( 'Y', strtotime( $timestamp ) );
		}
		return $year;
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [month] Shortcode

The Extra-Shortcodes plugin’s ‘month’ shortcode is a dynamic tool for displaying the month. It allows adjustments based on the ‘plus’ or ‘minus’ attributes. The ‘month’ shortcode can show the current month or a future/past month. If ‘plus’ is set, it displays the month that many months ahead. If ‘minus’ is set, it displays the month that many months ago. The default is the current month.

Shortcode: [month]

Parameters

Here is a list of all possible month shortcode parameters and attributes:

  • plus – Adds specified number of months to the current month
  • minus – Subtracts specified number of months from the current month
  • timestamp – Defines the current month based on a specified timestamp

Examples and Usage

Basic example – The shortcode displays the current month

[month /]

Advanced examples

Displays the month after 2 months from the current date. The ‘plus’ attribute is used to add the number of months to the current date.

[month plus=2 /]

Displays the month 3 months before the current date. The ‘minus’ attribute is used to subtract the number of months from the current date.

[month minus=3 /]

Displays the month of a specific date. The ‘timestamp’ attribute is used to specify the date. The date should be in ‘Y-m-d’ format.

[month timestamp='2022-12-25' /]

Combination of ‘plus’, ‘minus’ and ‘timestamp’ attributes. This shortcode will first calculate the date after adding 2 months to the ‘timestamp’ date, then it will subtract 1 month from that date to display the month.

[month timestamp='2022-12-25' plus=2 minus=1 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [month] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'month', array( __CLASS__, 'month_shortcode' ) );

Shortcode PHP function:

function month_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'plus' => 0,
			'minus' => 0,
			'timestamp' => 'now'
		), $atts ) );
		if ( !empty( $plus ) ) {
			$month = date( 'm', strtotime( '+'.intval($plus).' months' ) );
		} elseif ( !empty( $minus ) ) {
			$month = date( 'm', strtotime( '-'.intval($minus).' months' ) );
		} else {
			$month = date( 'm', strtotime( $timestamp ) );
		}
		return $month;
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [month_name] Shortcode

The Extra-Shortcodes plugin shortcode, ‘month_name’, dynamically displays the name of the month. It accepts parameters to add or subtract months from the current date.

Shortcode: [month_name]

Parameters

Here is a list of all possible month_name shortcode parameters and attributes:

  • plus – Adds a specified number of months to the current month.
  • minus – Subtracts a specified number of months from the current month.
  • timestamp – Specifies a particular date and time to display the month name.

Examples and Usage

Basic example – Display the current month name using the shortcode without any parameters.

[month_name /]

Advanced examples

Display the month name after a certain number of months. In this example, we will display the month name after 3 months.

[month_name plus=3 /]

Display the month name before a certain number of months. In this example, we will display the month name 2 months ago.

[month_name minus=2 /]

Display the month name for a specific timestamp. In this example, we will display the month name for the timestamp ‘2022-12-01’.

[month_name timestamp='2022-12-01' /]

These are just a few examples of how you can use the ‘month_name’ shortcode. By manipulating the ‘plus’, ‘minus’, and ‘timestamp’ parameters, you can customize the output to fit your specific needs.

PHP Function Code

In case you have difficulties debugging what causing issues with [month_name] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'month_name', array( __CLASS__, 'month_name_shortcode' ) );

Shortcode PHP function:

function month_name_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'plus' => 0,
			'minus' => 0,
			'timestamp' => 'now'
		), $atts ) );
		if ( !empty( $plus ) ) {
			$month_name = date( 'F', strtotime( '+'.intval($plus).' months' ) );
		} elseif ( !empty( $minus ) ) {
			$month_name = date( 'F', strtotime( '-'.intval($minus).' months' ) );
		} else {
			$month_name = date( 'F', strtotime( $timestamp ) );
		}
		return $month_name;
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [day] Shortcode

The Extra-Shortcodes plugin’s ‘day’ shortcode is used to display the current day, with the ability to add or subtract days. This shortcode accepts three parameters: ‘plus’, ‘minus’, and ‘timestamp’. The ‘plus’ parameter increments the current date, while ‘minus’ decrements it. The ‘timestamp’ parameter sets the date to a specific time.

Shortcode: [day]

Parameters

Here is a list of all possible day shortcode parameters and attributes:

  • plus – Number of days to add to the current date
  • minus – Number of days to subtract from the current date
  • timestamp – Specific date to be displayed

Examples and Usage

Basic example – Displays the current day using the ‘day’ shortcode without any parameters.

[day /]

Advanced examples

Displays the date of a day that is 3 days ahead of the current day. Here, the ‘plus’ parameter is used to add 3 days to the current date.

[day plus=3 /]

Displays the date of a day that is 5 days before the current day. Here, the ‘minus’ parameter is used to subtract 5 days from the current date.

[day minus=5 /]

Displays the date of a specific timestamp. Here, the ‘timestamp’ parameter is used to set a specific timestamp.

[day timestamp="2022-03-01 12:00:00" /]

Note: The timestamp should be in the format “YYYY-MM-DD HH:MM:SS”.

PHP Function Code

In case you have difficulties debugging what causing issues with [day] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'day', array( __CLASS__, 'day_shortcode' ) );

Shortcode PHP function:

function day_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'plus' => 0,
			'minus' => 0,
			'timestamp' => 'now'
		), $atts ) );
		if ( !empty( $plus ) ) {
			$day = date( 'd', strtotime( '+'.intval($plus).' days' ) );
		} elseif ( !empty( $minus ) ) {
			$day = date( 'd', strtotime( '-'.intval($minus).' days' ) );
		} else {
			$day = date( 'd', strtotime( $timestamp ) );
		}
		return $day;
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [weekday] Shortcode

The ‘weekday’ shortcode from Extra-Shortcodes plugin is a simple yet powerful tool. It returns the day of the week based on the given parameters. The ‘weekday’ shortcode allows customization with ‘plus’, ‘minus’, and ‘timestamp’ attributes. If ‘plus’ is set, it returns the day of the week for the upcoming days. If ‘minus’ is set, it returns the day for the past days. The ‘timestamp’ attribute returns the day for the given timestamp.

Shortcode: [weekday]

Parameters

Here is a list of all possible weekday shortcode parameters and attributes:

  • plus – Number of days to add to the current date.
  • minus – Number of days to subtract from the current date.
  • timestamp – Specific date and time to display the weekday for.

Examples and Usage

Basic example – Display the current weekday

[weekday /]

With the above shortcode, you will be able to display the current weekday on your WordPress site. This shortcode doesn’t require any attributes or parameters, making it a simple and straightforward way to display the current day of the week.

Advanced examples

Display the weekday for a specific date

[weekday timestamp="2022-02-15" /]

In this example, the shortcode will display the weekday for the date specified in the timestamp attribute. Replace “2022-02-15” with any date you want to know the weekday of.

Display the weekday for a date certain days in the future

[weekday plus="3" /]

This shortcode will display the weekday for a date three days in the future. You can replace “3” with any number of days you want to add to the current date.

Display the weekday for a date certain days in the past

[weekday minus="2" /]

With this shortcode, you can display the weekday for a date two days in the past. Replace “2” with any number of days you want to subtract from the current date.

PHP Function Code

In case you have difficulties debugging what causing issues with [weekday] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'weekday', array( __CLASS__, 'weekday_shortcode' ) );

Shortcode PHP function:

function weekday_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'plus' => 0,
			'minus' => 0,
			'timestamp' => 'now'
		), $atts ) );
		if ( !empty( $plus ) ) {
			$weekday = date( 'l', strtotime( '+'.intval($plus).' days' ) );
		} elseif ( !empty( $minus ) ) {
			$weekday = date( 'l', strtotime( '-'.intval($minus).' days' ) );
		} else {
			$weekday = date( 'l', strtotime( $timestamp ) );
		}
		return $weekday;
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [hours] Shortcode

The Extra-Shortcodes plugin’s ‘hours’ shortcode is designed to manipulate time. It allows users to add or subtract hours from the current time. The shortcode accepts three parameters: ‘plus’, ‘minus’, and ‘timestamp’. ‘Plus’ adds hours to the current time, ‘minus’ subtracts, and ‘timestamp’ displays the current hour.

Shortcode: [hours]

Parameters

Here is a list of all possible hours shortcode parameters and attributes:

  • plus – Adds the specified number of hours to the current time.
  • minus – Subtracts the specified number of hours from the current time.
  • timestamp – Specifies a particular time to use instead of the current time.

Examples and Usage

Basic example – Display the current hour

[hours /]

Advanced examples

Display the hour after adding a certain number of hours. In this example, we are adding 3 hours to the current time.

[hours plus=3 /]

Display the hour after subtracting a certain number of hours. In this example, we are subtracting 2 hours from the current time.

[hours minus=2 /]

Display the hour for a specific timestamp. In this example, the timestamp is for 2022-01-01 00:00:00.

[hours timestamp='2022-01-01 00:00:00' /]

Display the hour after adding a certain number of hours to a specific timestamp. In this example, we are adding 5 hours to the timestamp for 2022-01-01 00:00:00.

[hours plus=5 timestamp='2022-01-01 00:00:00' /]

Display the hour after subtracting a certain number of hours from a specific timestamp. In this example, we are subtracting 1 hour from the timestamp for 2022-01-01 00:00:00.

[hours minus=1 timestamp='2022-01-01 00:00:00' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [hours] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'hours', array( __CLASS__, 'hours_shortcode' ) );

Shortcode PHP function:

function hours_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'plus' => 0,
			'minus' => 0,
			'timestamp' => 'now'
		), $atts ) );
		if ( !empty( $plus ) ) {
			$hours = date( 'H', strtotime( '+'.intval($plus).' hours' ) );
		} elseif ( !empty( $minus ) ) {
			$hours = date( 'H', strtotime( '-'.intval($minus).' hours' ) );
		} else {
			$hours = date( 'H', strtotime( $timestamp ) );
		}
		return $hours;
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [minutes] Shortcode

The ‘minutes’ shortcode from the Extra-Shortcodes plugin allows you to manipulate time in WordPress. It accepts three parameters: ‘plus’, ‘minus’, and ‘timestamp’. If ‘plus’ is set, it adds the specified minutes to the current time. Similarly, ‘minus’ subtracts minutes. If neither is set, ‘timestamp’ returns the current minute.

Shortcode: [minutes]

Parameters

Here is a list of all possible minutes shortcode parameters and attributes:

  • plus – Adds specified number of minutes to the current time.
  • minus – Subtracts specified number of minutes from the current time.
  • timestamp – Specifies a certain time to be displayed.

Examples and Usage

Basic example – Display the current minute of the hour

[minutes /]

Adding minutes to the current time. This shortcode will return the minute of the hour after adding 30 minutes to the current time.

[minutes plus=30 /]

Advanced examples

Subtracting minutes from the current time. This shortcode will return the minute of the hour after subtracting 15 minutes from the current time.

[minutes minus=15 /]

Using a specific timestamp. This shortcode will return the minute of the hour for the specified timestamp. The timestamp should be in a format that can be parsed by the PHP strtotime function. In this example, the timestamp is set to ‘2022-01-01 14:30:00’.

[minutes timestamp='2022-01-01 14:30:00' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [minutes] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'minutes', array( __CLASS__, 'minutes_shortcode' ) );

Shortcode PHP function:

function minutes_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'plus' => 0,
			'minus' => 0,
			'timestamp' => 'now'
		), $atts ) );
		if ( !empty( $plus ) ) {
			$minutes = date( 'i', strtotime( '+'.intval($plus).' minutes' ) );
		} elseif ( !empty( $minus ) ) {
			$minutes = date( 'i', strtotime( '-'.intval($minus).' minutes' ) );
		} else {
			$minutes = date( 'i', strtotime( $timestamp ) );
		}
		return $minutes;
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Extra Shortcodes [seconds] Shortcode

The Extra-Shortcodes plugin’s ‘seconds’ shortcode is a versatile tool. It displays the current second of the minute, with options to add or subtract seconds. The shortcode takes three parameters: ‘plus’, ‘minus’, and ‘timestamp’. ‘Plus’ adds seconds to the current time, ‘minus’ subtracts seconds, and ‘timestamp’ sets a specific time. It then returns the current second of the minute.

Shortcode: [seconds]

Parameters

Here is a list of all possible seconds shortcode parameters and attributes:

  • plus – Adds specified number of seconds to the current time
  • minus – Subtracts specified number of seconds from the current time
  • timestamp – Sets the current time to the specified timestamp

Examples and Usage

Basic example – A simple usage of the ‘seconds’ shortcode with no additional parameters. This will return the current seconds of the server’s time.

[seconds /]

Advanced examples

Adding seconds to the current time – Here, we’re using the ‘plus’ attribute to add a certain number of seconds to the current time. For instance, if we want to add 45 seconds:

[seconds plus=45 /]

Subtracting seconds from the current time – In this example, we’re using the ‘minus’ attribute to subtract a certain number of seconds from the current time. For instance, if we want to subtract 30 seconds:

[seconds minus=30 /]

Specifying a timestamp – Here, we’re using the ‘timestamp’ attribute to specify a certain time. This will return the seconds of the provided timestamp. For example, if we want the seconds of ’10:15:30′ time:

[seconds timestamp="10:15:30" /]

Combining attributes – In this example, we’re using both ‘plus’ and ‘timestamp’ attributes. This will add the specified number of seconds to the provided timestamp. For instance, if we want to add 10 seconds to ’10:15:30′ time:

[seconds plus=10 timestamp="10:15:30" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [seconds] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'seconds', array( __CLASS__, 'seconds_shortcode' ) );

Shortcode PHP function:

function seconds_shortcode( $atts ) {
		extract( shortcode_atts( array(
			'plus' => 0,
			'minus' => 0,
			'timestamp' => 'now'
		), $atts ) );
		if ( !empty( $plus ) ) {
			$seconds = date( 's', strtotime( '+'.intval($plus).' seconds' ) );
		} elseif ( !empty( $minus ) ) {
			$seconds = date( 's', strtotime( '-'.intval($minus).' seconds' ) );
		} else {
			$seconds = date( 's', strtotime( $timestamp ) );
		}
		return $seconds;
	}

Code file location:

extra-shortcodes/extra-shortcodes/extra-shortcodes.php

Conclusion

Now that you’ve learned how to embed the Extra Shortcodes Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *