Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; WPShortcodeExecPHP has a deprecated constructor in /home/wescleveland/public_html/ on line 78

Deprecated: Function create_function() is deprecated in /home/wescleveland/public_html/ on line 190
wp247 Get Option Shortcode - WordPress 24x7

We’ve all been there, hard coded some text in our WordPress sites that exists in a WordPress option and then later changed the WordPress option value but forgot about the hard coded text throughout our website. Then, later discovered the inconsistency and had to go through and find and fix all occurrences of the hard coded text.

I am a big fan of the Shortcode Exec PHP WordPress plugin and have used it some for this type of situation. I would set up a specific shortcode for each type of data I needed. It became apparent that many of these shortcodes were pulling WordPress options data. So, to make life a little easier, I created a WordPress plugin to retrieve options data via a shortcode.

Introducing the WP247 Get Option Shortcode WordPress plugin. This plugin allows you to include WordPress options anywhere shortcodes are accepted.


[wp247_get_option option=”desired-option” default=”desired-default” scope=”desired-scope“]


desired-option is the option to be retrieved from the WordPress wp_options table.
Default: none

desired-default is the default value to be returned if the desired option does not exist.
Default: “”

desired-scope indicates which type of option is to be retrieved. scope=”site” will retrieve options using the WordPress get_site_option function. All other values are ignored and the WordPress get_option function will be used to retrieve the desired option value.
Default: “”


Include the WordPress site URL in some text somewhere:

This is my site’s URL: [wp247_get_option option=”siteurl”].

results in:

This is my site’s URL:

Set up a copyright notice in a footer widget:

Copyright &copy; <a href=”[wp247_get_option option=’siteurl’]”>[wp247_get_option option=’blogname’]</a>. All rights reserved.

results in:

Copyright &copy; <a href=”“>WordPress 24x7</a>. All rights reserved.

displays as:

Copyright © WordPress 24x7. All rights reserved.


One Comment

  1. Web Hosting April 15, 2017 at 11:37 pm

    WordPress automatically adds paragraphs and line breaks to content formatted in the editor, so if your shortcodes aren t formatted just right, you ll see a lot of extra spacing.


Leave a Reply

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




Theme by HermesThemes

Copyright © 2020 WordPress 24x7. All Rights Reserved