Filter only shortcode from a post
I am using a contact page plugin for my blog.The shortcode using for this is
[my-shortcode]
.
Is ther开发者_JS百科e anyways to filter only the shortcode from the content.
Eg:
Test post [my-shortcode] Demo widget
.here i need to filter only the shortcode.Thank you
You can use regex to get the value of brackets within a string like so.
if(preg_match_all('/\[(.*?)\]/',$_POST['my_key'],$matches))
{
foreach($matches as $match)
{
if($match[1] == 'my-short-code')
{
//Do whetever
break 2;
}
}
}
Note: match[1]
may be match[0]
精彩评论