Used shorcodes can be retrived only if they are added in post content (or any content saved in db). They can not be retrived if hardcoded in template files (TBH, they can, but that’s not the issue here). This code can help you to get the shortcodes used in a post content.
function wpse387291_get_shortcodes() {
global $post;
$pattern = get_shortcode_regex();
if ( preg_match_all( "https://wordpress.stackexchange.com/". $pattern .'/s', $post->post_content, $matches ) {
//$matches will hold the shortcodes if any
echo '<pre>' . print_r( $matches, true ) . '</pre>';
}
}
add_action( 'wp', 'wpse387291_get_shortcodes' );
You can use any hook that runs after wp
.
Related Posts:
- Using action hooks inside of a shortcode
- Enclosing Shortcode Within Another Enclosing Shortcode Breaks Output Functionality
- Which method to use when deleting posts from the front-end
- Why are you using add_action for shortcode?
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Pros and cons of actions over shortcodes
- manipulate a plugins shortcode
- Print shortcode in custom action hook not where the shortcode is entered
- Remove and restore one shortcode
- passing parameters to do action from shortcode to wp_footer
- Convert HTML Script to Shortcode [closed]
- Use another action instead of the shortcode API to display the last time a user logged in
- Modifying the wordpress login page and then referencing it with a shortcode problem
- contact form 7 :create shortcode usable in email message [closed]
- How to create shortcode for auto login after registration
- Hook into existing shortcodes to manipulate the attributes?
- What hook runs wpautop on template content?
- Custom WP theme not showing shortcodes
- How to stop unwanted splits in excerpts when using shortcodes for sliders or players
- Code auto escaping is not working when using short codes
- Shortcode for sectors
- How to add a nested shortcode into editor?
- WP_Editor Shortcode Issue
- Shortcodes: Return different based on atts
- How to add meta slider lite or other slider to main page header in pinboard theme
- Shortcode not working in custom post types
- What is the best way to include a template file within a shortcode?
- Shortcode or placeholder for theme options page?
- load plugin with ajax [duplicate]
- Str_replace using shortcode with multiple changes
- Custom shortcode that writes to file
- How to print [embed] code in wordpress [duplicate]
- Changing layout of defaul gallery output to masonry
- What makes a placeholder resizable in Tinymce?
- shortcode change variable base on user
- Inserting shortcode is blanking excerpt – any ideas?
- short code is not working in in custom wordpress theme it’s only working in default theme
- short code output too early
- Shortcodes that are created based on user input information
- Shortcode with multiple variables
- short code output too early
- Remove some tags from shortcodes output? Trying to fix autop
- do_shortcode & render custom field won’t work
- shortcodes inside shortcode to sum values
- is_mobile as shortcode
- Escaping a shortcode so it displays as-is [duplicate]
- About redundant code when I use shortcode to output the HTML from a variable
- frontend show edit profile with selected custom options
- WordPress do_shortcode first iteration
- add php shortcode in return function
- how to show last 5 images from the one post gallery
- Redirect back to origin page after using get_delete_post_link()
- Create action running on trashed_post hook to modify post_meta value
- OOP Plugin: Where should I place the action hooks in the class?
- Shortcodes in Options Panel textareas
- Display post_meta in Shortcode
- Shortcode Attribute
- Gallery Shortcode: using size=”full” doesn’t call the actual thumbnail image size
- Can’t get default values to work with custom shortcode
- How to attach sidebar to shortcode’s output?
- loop on page makes shortcode fail
- If do_shortcode is blank, return some message
- How to add custom checkout field in user details mail template
- Is it possible to change a shortcode parameter based on a media query?
- add query string to all pages after user logged in
- How to not show shortcode contents if cart is empty?
- Shortcode templates
- Add a short code to a plugin
- style css to header for shortcodes
- Add JavaScript in footer if shortcode used in page [duplicate]
- How wordpress plugin hooks works? [duplicate]
- Can not get shortcode content in function
- Is there a way I can return terms by name using a shortcode?
- How do I override the user’s input when updating a custom post type’s permalink?
- WordPress Shortcode loads at the top
- Shortcode Output Always Before Content [duplicate]
- woocommerce Product shortcode create [closed]
- How to add a new link to the default register form’s footer links?
- How to Convert Shortcode into a link?
- Question about do_shortcode
- The acction hook stop working if i move it from plugin file to theme’s functions.php file
- Shortcode append to the the_content()
- admin_post hook not working
- A number appears inside a div called wpb_wrapper, when I use a custom shortcode
- Cannot modify header information – headers already sent
- Enclose article’s body with default shortcode
- How create a shortcode with html
- Adding shortcode [closed]
- do_shortcode autommatic content generation
- Previous/Next with the same category
- I’ve broken the short code for Contact Form 7!
- echo a shortcode in a shortcode code?
- wp_register_script and wp_register_style when shortcode is used
- Create plugin/function to catch XML-data via Shortcode
- Applying if (get_post_meta) to new shortcode
- Why My slider shortcode display above header
- How i make a shortcode from this code
- What does this shortcode do?
- Shortcode Attributes – post__not_in array
- IFrame Shortcode plugin – issue