• Resolved vesnama

    (@vesnama)


    Hello,

    I’m trying to solve gallery inclusion in Pods template.

    This is what I’m trying to achieve:

    • I have created custom field for media files. It is a relationship field with a drop-down list to choose from published posts. This means media files belong to the chosen post.
    • I also have custom taxonomy for media files that defines type of photo (premiere, costumes, rehearsal, audience…).
    • For displaying post I’m using Pods template replacing the_content hook. Now I do not know what shortcode or magic tag to use to display for current post the gallery of media files related to current post and which also have specific photo type Taxonomy (for example “costumes”).
    • Is it possible in Pods template with some easy magic tag variable to choose if gallery is displayed as slider or lightbox or some layout which some gallery plugins offer?
    • Thank you as always for your valuable helpful replies. ??

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter vesnama

    (@vesnama)

    I forgot to add the main question from the title of this post…

    • Maybe the easiest way to display via Pods template a gallery related to current post with layout through one of those cool plugins for galleries would be if I could have a custom field “gallery shortcode” to enter full shortcode for example [gallery_plugin album=premiere layout=masonry columns=4], and then put in a Pods template the value of a field “gallery shortcode” to execute the shortcode on the front-end.
    • Hope you can explain how to do it in Pods template in any of two ways I was thinking about? Thank you.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @vesnama

    Our magic tags are meant for direct output, if you need functionality from other plugins you should see the display filter and use PHP to reformat the output.
    https://docs.pods.io/displaying-pods/magic-tags/display-filters-with-magic-tags/

    Keep in mind that this is considered advanced usage and documentation is limited because there are simply way to many use cases.
    You should look at the gallery/lightbox/slider plugin documentation on how to format the data etc.

    Cheers, Jory

    Thread Starter vesnama

    (@vesnama)

    I understand this:
    {@field_name,any_function}

    So I am putting in Pods template this:
    {@robo_gallery.ID,show_robo_gallery}

    Is this correct to send ID of the robo gallery post to the function?
    If I put in the Pods template only {@robo_gallery.ID} then the correct ID is displayed, I tested.

    And I understand I must create function show_robo_gallery inside function.php.

    But I do not understand how this function is constructed to activate in the Pods template this shortcode

    [robo-gallery id=”2068″]

    where value for id is the ID value i sent via
    {@robo_gallery.ID,show_robo_gallery}

    Thread Starter vesnama

    (@vesnama)

    Solved!

    Here is the solution for future inquiries…

    I added this to function.php (not directly, I’m using plugin Code snippets so I don’t have to worry about wordpress updates overwriting it):

    /**
     * Allow Pods Templates to use shortcodes
     *
     * NOTE: Will only work if the constant PODS_SHORTCODE_ALLOW_SUB_SHORTCODES is
     * defined and set to true, which by default it IS NOT.
     */
    add_filter( 'pods_shortcode', function( $tags )  {
      $tags[ 'shortcodes' ] = true;
      
      return $tags;
      
    });
    
    /**
    * Allow shortcodes in a Pods Template
    */
    add_filter( 'pods_templates_post_template', 'do_shortcode', 10, 1 );
    
    /**
     * Run shortcodes on the <code>get_the_author_description</code> hook.
     */
    add_filter( 'get_the_author_description', 'do_shortcode' );
    
    /**
     * Run shortcodes on the <code>the_content</code> hook.
     */
    add_filter( 'the_content', 'do_shortcode' );

    And in Pods template I added this:
    [robo-gallery id={@robo_gallery.ID}]

    And the shortcode using ID value from bidirectional relationship field from custom type Robo gallery displays masonry gallery i wanted! ??????

    Excellent! I love Pods! ??????

    Plugin Author Jory Hogeveen

    (@keraweb)

    Great to see you’ve solved it! Thanks for sharing.

    Cheers, Jory

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get custom field value in the shortcode’ is closed to new replies.