We're merging with GenerateBlocks! Learn more here.

[Support request] Shortcode for Pods Taxonomies?

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Shortcode for Pods Taxonomies?

  • This topic has 8 replies, 2 voices, and was last updated 3 years ago by Tom.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #15686
    Bodie J
    Participant

    Hey Tom!

    I am building a photo and video timeline on my website using a Custom Post Type called “Timeline Events” (timeline_event) that I built with Pods. Along with that I built two custom taxonomies inside Pods that go with that post time called timeline_category and timeline_tag. I am using WPSP mostly as a “related posts” section for each event to link to other events with the same timeline category or timeline tag.

    I have tried to modify a shortcode you provided in another thread for showing taxonomies, but it doesn’t seem to work. For example I have a tag for each year. I want to created 1 WPSP list for Tags and use the same shortcode everywhere, just changing the tax_term property to the relevant tag. For example:

    [wp_show_posts id=”3533″ settings=”taxonomy=timeline_tag&tax_term=2020″]

    This doesn’t seem to work. Is there a better way to do related posts without having to duplicate the same list over and over again? Secondly, some of the categories in the timeline_category taxonomy don’t even show up in the list inside the WPSP dashboard. I was hoping a single list with customizing the shortcode per tag would solve both issues.

    Love some help and insight!

    Thanks

    #15714
    Tom
    Keymaster

    Hey Bodie,

    Where would the tax_term value come from?

    If we add the list to the page dynamically using PHP, we can use a dynamic field to change that value depending on where we area.

    As for the categories not showing up – do they have published posts in them?

    #15739
    Bodie J
    Participant

    Hey Tom,

    Thanks for the response. I have designated the timeline_category and timeline_tag taxonomies to only show up on the timeline-event post type in the Pods settings. So by checking a particular box in the settings, would that count as setting the tax_term setting? Like my selecting the April timeline category and 2020 as the timeline tag in the image below?

    Timeline Settings Image

    I would love to add the list dynamically! How do I do that? Being able to do that would negate my need for shortcode adjustment every time. I am always going to want to link content that the current post itself contains such as the timeline_category or timeline_tag to other posts with the same settings.

    And to answer your question about the categories, no, I just realized that I don’t think I have have posts published with those tags, so that makes sense.

    #15750
    Tom
    Keymaster

    Ah, in that case we should just be able to get the current tax term and fill in the blank in the function.

    Where is the list showing up? Can we hook it in somewhere instead of adding it to the content?

    #15754
    Bodie J
    Participant

    I currently have two GenerateBlocks containers at the bottom of my timeline_event single post layout. Each container block has a Headline block inside that contains the WPSP shortcodes.

    So guess I could just create a timeline-event-single.php file and you could help with a function that hooks in after the regular post content? Oh man, if I could do that and have them automatically generate, I would be thrilled. I LOVE the Cards look and want to have them at the bottom of all my timeline events for easy linking to other posts that share those taxonomies.

    It’s broken right now, but as far as content and layout goes, here is the idea: https://bodiequirk.com/timeline-event/easter-2020/

    Here are the blocks

    Thanks for your help!

    #15797
    Tom
    Keymaster

    As an example, this is the function you’d use:

    <?php
    $object = get_queried_object();
    
    if ( isset( $object->term_id ) ) {
        $settings = array(
            'taxonomy' => 'timeline_tag',
            'tax_term' => $object->term_id,
        );
    
        wp_display( 123, $settings );
    }
    ?>

    So this would target the 123 list ID, and it will fill in the tax_term with the current term ID.

    #15801
    Bodie J
    Participant

    This is great! A couple follow-up questions:

    1) Where would you recommend this code go so as to show up after the content in my timeline_event post type single posts?
    2) Do I need a GeneratePress hook as well? If so, I would need help writing that function
    3) What would be the best way to do this multiple times on the same page? Since I have both the timeline_tag and the timeline_category posts that I want to render out, is there a way to hook them both into the post after the content?

    I wish I was better at PHP for moments like these.

    Thanks Tom

    #15818
    Bodie J
    Participant

    Sorry for the dual post, I realized that was able to answer some of my own questions (Elements, hello?)

    I am still not able to get it to work, but maybe I am going about it all wrong?

    Here is a screenshot of my settings.

    1) Created a GP Hook Element
    2) Put the provided code in and tweaked it to show the appropriate list and taxonomy
    3) Configured all the settings for the WPSP list as well as the GP Element to show up in Timeline Entries.

    I am still not able to see anything show up in my post, but I know we are getting closer!

    Sorry to keep at this, but this is such a key feature for me. Once I figure this out, it will save me buckets of time in future timeline entries.

    Thanks!

    #15850
    Tom
    Keymaster

    That looks good – something must not be making it through.

    Can you add this filter as regular PHP?:

    add_filter( 'wp_show_posts_shortcode_args', function( $args ) {
        var_dump($args);
        return $args;
    } );

    Does it output anything where the list should display?

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.