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?
- Custom shortcode being executed when saving page in wp-admin
- Change appearance of shortcode text inside editor
- Getting instance variable in scope of ‘wp_enqueue_scripts’
- WordPress gallery ‘post_gallery’ filter doesn’t work with feeds?
- Ajax not returning anything on form submit
- How can I hook into existing WordPress Bulk actions?
- add_action on inherit post status
- How do I add my own custom shortcodes?
- Hooking new functions to actions + passing parameters
- wp_ajax action is not running
- action lifecycle
- Redirect users on specific post category or category page
- On WordPress 4.4, how to get the post id using the comment_post hook
- Filter or action hook to insert content on admin pages before tag
- Slow page loading when using a simple shortcode on the same page multiple times
- Is it possible to delay execution of shortcode output callback?
- Using do_shortcode with variables?
- Using ACF field in do_shortcode()
- Display content from another site page using a shortcode
- Remove hyperlink on gallery shortcode
- Combining similar shortcode functions?
- How to build a shortcode which can insert a query string into a DB table
- What is the Correct way to pass parameters in function
- Shortcode – Getting Categories appears on top of website
- Visual Composer integration [closed]
- How to Modify WordPress Default Image Gallery Shortcode
- Passing html tags as shortcode parameters
- Button Shortcode
- How do I trigger a post update within a get_posts() foreach loop?
- Hook when editing user
- Using shortcode to display array in array
- Add the last viewed post title to a contactform with shortcode [closed]
- Adding a template part as part of a shortcode
- Just display content between shortcode brackets
- How can I output all apply_filters and do_action?
- How can i share codes on my blog?
- How to explode single string IF it’s used in shortcode
- Use remove_meta_box conditionally on custom post type
- Check if CTP category taxonomy is set in shortcode
- Hook add_attachment error
- WooCommerce: after install hook
- how can i pass this attribute in this shortcode?
- How to add a same div on every page
- Display a form partially with a shortcode
- How do I add something to the “Edit Tag” page in wp-admin?
- Changing where my author box is printed
- What is the action hook to use if you want to capture the new password during password change?
- Render shortcodes with get_post_custom
- What hook to use to redirect based on $post
- Set redirect for need login
- make user_id in a shortcode dynamic based on who’s logged in
- Image Caption Shortcode Broken upon update
- update_option_{$option} not working (do function after options are saved)
- Shortcode not working in CPT taxonomy
- wp_enqueue_scripts does not work on admin page
- shortcode containing other shortcodes not returning content
- To know whether insert shortcode in custom meta box
- Shortcodes not working in custom page
- Get label in user meta query
- Shortcode not being executed
- Load gravity form via ajax using do_shortcode
- Video Short Code and Media Fragments URI
- remove_action – pre_get_posts – does not restore original query
- How to process a single attribute in a SQL request twice times?
- Check get_post value after wp-admin login
- How to fix transparency in product sliders / featured products on home page?
- Short code format for cat tagging when posting from email
- How can I set a dynamic value for post_updated_messages based on return value of post_updated?
- How do I use “while” and “end while” inside of the echo do_shortcode with ACF Repeater?
- Problem in creating a shortcode form custom post type slider
- frontend show edit profile with selected custom options
- add php shortcode in return function
- style css to header for shortcodes
- What does this shortcode do?
- create shortcodes for posts
- How Do I create a shortcode to dispaly a go to top button on any page or post
- Identifying first and last instance of shortcode in post
- Executing a shortcode at the top of PAGE template?
- Display a block conditionally based on user input button
- Add text when displying attribute with a hook on single product page
- Custom shortcode with < in content
- Product description is mixed in shortcodes
- Why does my JavaScript work in the browser console but does not work in my shortcode?
- add_action to only be called if uploading media from the front end