Think about a post content like below:
[shortcode a="a_param"]
... Some content and shortcodes here
[shortcode b="b_param"]
.. Again some content here
[shortcode c="c_param"]
I have a shortcode that takes 3 or more parameters.
I want to find out how many times the shortcode is used at the content and its parameters in an array like,
array (
[0] => array(a => a_param, b=> null, c=>null),
[1] => array(a => null, b=> b_param, c=>null),
[2] => array(a => null, b=> null, c=>c_param),
)
I need to do this in the_content filter, wp_head filter or something similar.
How can I do this ?
Thank you,
In wordpress get_shortcode_regex() function returns regular expression used to search for shortcodes inside posts.
Then preg_match the pattern with the post content
If it return true, then extracted shortcode details are saved in $matches variable.
Try
Just to save time, this is the function I made based on @Tamil Selvan C answer :