WordPress Code Snippets

A fresh mix of code snippets and tutorials

WordPress Display Version Number

252

Here is a simple function to display the current version number for WordPress.

Update! I can’t believe I missed this: there is already a WP function for displaying the current version number:

get_bloginfo('version')

Thanks to Piet B. for bringing it my attention!

</update>

So let’s say that you want to display the version number for your current copy of WordPress. Easy. Just add the following function to your theme’s functions.php file (or can add via plugin file):

Then you can display the version number virtually anywhere in your theme template, plugin settings, or wherever:

<?php echo shapeSpace_current_version(); ?>

So if the site is running WordPress version 4.6, the function will output exactly that, “4.6”. Thus you can do something like this in your theme template:

<p>Congratulations, you are running WordPress version <?php echo shapeSpace_current_version(); ?>!</p>

..which would display:

Congratulations, you are running WordPress version 4.6!

Bonus: Make it a Shortcode

The beauty of WordPress is its flexibility. For example, we can make the previous function a shortcode by adding one line after the function, like so:

So while the first function enables us to display the version number anywhere in the theme template, this second shortcode function enables us to display the version number in any Post or Page. The shortcode to use is [current_version].

Enjoy! :)

Learn more

WordPress Themes In Depth


Show Support

Like our new Facebook Page to show support!