Support » Plugin: Pods - Custom Content Types and Fields » get pods template name

  • Resolved kabouton


    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

Viewing 1 replies (of 1 total)
  • Plugin Author Jory Hogeveen


    There is a filter called pods_shortcode which passes all tags that are send to the shortcode (+ default/missing tags) before parsing them.

    Cheers, Jory

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.