Shortcodes, as I understand them, are to be used inside content of pages/posts, and (with 4.9) widgets. They aren’t supported inside other spots on the page, only in the page/post/widget content.
From the Codex: https://codex.wordpress.org/Shortcode
[WP] only expands the shortcodes within the content of a Post, Page,
or custom post type.
But I don’t think your code should be setting a shortcode. Perhaps it should be setting a global variable that will be used elsewhere. (But it is late, and I am under the influence of excessive turkey…)
Related Posts:
- Solution to render Shortcodes in Admin Editor
- Add tags to the section via functions.php
- Use AJAX in shortcode
- Include PHP file in Content using [shortcode]
- Shortcode producing headers already sent error
- How to add attributes to a shortcode
- How to display random users with avatars
- Enabling shortcodes for custom fields
- How to use get_media_embedded_in_content function
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Shortcode with parameters inside parameters
- Creating a table from shortcode avoiding wpautop for each row
- Change meta tags programatically
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Stripping shortcode from custom excerpt function
- how to create shortcode in wordpress
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- Display random text from a file with the WP built-in AJAX API
- Set first oembed in post to a global variable or function
- Formatting post content to exclude gallery
- Remove images from get_the_excerpt
- Shortcode with custom content attribute?
- Problem with extract() with custom shortcode
- Shortcode to insert menu in page body?
- Using locate-template & shortcodes doesn’t appear to work
- Displaying a random user with a shortcode
- Passing HTML in WordPress Shortcode arguments
- Adding body class when post contains a specific shortcode
- How to add iOS & fav icons to the theme?
- Function to show only first instance of shortcode
- Display a text message if the shortcode is found?
- Trying to inject twitter metadata into using wp_head action in functions.php – get_the_excerpt() returns null
- Need help making a short code work
- Using One Function To Create Two Different Shortcodes
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- Display a list of random terms from custom taxonomy with shortcode
- Load templates, pass arguments, and render output from functions.php
- How to add if statement on WordPress shortcode output
- Passing function arguments via a shortcode
- Pagination not working – FrontPage
- Customizing the wp_video_shortcode output with add_filter
- page shows short code not output
- Probleme shortcode with list author
- Function to function shortcode help [closed]
- Last updated posts shortcode in functions.php
- Hide author info in single posts by certain users
- I want to display the sku in the product pages of my EDD website
- Shortcode to output category description by passing ID
- Help using ShortCodes to style whole chunks of the post
- Shortcode to insert default text and change one word throughout it?
- use add_action in a shortcode (gravity form – WordPress)
- Shortcode displaying outside the div [duplicate]
- Shortcode Initialization in a Custom Theme
- Shortcode with pagination advancing multiple queries
- Show users last read posts for each user?
- Get shortcode attribute value to another function
- How to retrieve image IDs from shortcode content?
- Display list of pages that contain a certain string within the slug
- Placing CSS/ JS into the header or footer (inline) – trying to apply to several templates
- Hide disclaimer from summary excerpts
- HowTo: Add wrapper to columns shortcode?
- Function not receiving string from shortcode
- How To Show Shortcodes In WordPress Custom Fields?
- Edit meta fields from within template
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Custom shortcode with do_shortcode and substr
- Shortcode to eliminate and replace with
- custom COOKIE on custom page
- Can I use a function to return HTML and the result of another function?
- Problem in outputting shortcode
- Problem in shortcode outputting content
- Expanding a function to call a plugin or show a link
- Trying to the deduce shortcode from a function
- How to display data from custom fields in my custom shortcode?
- Modify function Shortcode_atts
- Pull random comment from specific post, display on homepage with shortcode
- Set thumbnail from URL, by grabbing image in functions.php
- Shortcode to output get_header not working
- restrict access to specific urls on a specific period of time
- using enqueue_script in a shortcode isn’t working
- Run function from parent on child site
- Echo a div to header.php from functions.php
- Gallery Shortcode Function Help
- Add title & subtitle to shortcodes
- Echo custom field value in shortcode function
- Shortcode Variations?
- Shortcodes not outputting in correct divs
- shortcode inside post called by ID does not render as expected
- Custom shortcode not being included in content paragraph [duplicate]
- trouble with passing class method data to outside function
- new to javascript – using in instead of functions.php, not loading correctly
- Get term count on a category page
- How do grab the main loop, with conditions, and output via shortcodes
- Display function from functions.php in tag.php
- Creating mixture of shortcodes to use in the visual/text editor
- PHP error in shortcode [closed]
- multible shortcodes (for differnt values) with one function
- wp_head not injecting css
- post_content return zero!
- How to make my logged-in user-role shortcode displaying name instead of slug?