Replies: 0
Is there a way to get the name of a template being called with a pods shortcode on a page? I want to do something on that page depending on the pods template name.
For example – I have a page with a shortcode [pods name="mypods" limit="-1" template="myTemplate"]
In my function.php I want to set a variable to be podstemplateName = “myTemplate”
I currently can get it with
if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'pods') ) {
// get the attributes of the pods shortcode
preg_match_all( '/' . get_shortcode_regex() . '/', $post->post_content, $matches, PREG_SET_ORDER );
$pods_shortcode_atts = shortcode_parse_atts($matches[0][3]);
and it is in $matches
but I was looking for a nicer way
Thanks