Home › Forums › Pro Support › Shortcode for Pods Taxonomies?
Tagged: custom post type, Pods, shortcode
- This topic has 8 replies, 2 voices, and was last updated 3 years, 6 months ago by
Tom.
-
AuthorPosts
-
May 18, 2020 at 7:13 pm #15686
Bodie J
ParticipantHey 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 calledtimeline_category
andtimeline_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
May 19, 2020 at 4:51 pm #15714Tom
KeymasterHey 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?
May 19, 2020 at 11:16 pm #15739Bodie J
ParticipantHey Tom,
Thanks for the response. I have designated the
timeline_category
andtimeline_tag
taxonomies to only show up on thetimeline-event
post type in the Pods settings. So by checking a particular box in the settings, would that count as setting thetax_term
setting? Like my selecting theApril
timeline category and2020
as the timeline tag in the image below?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.
May 20, 2020 at 2:46 pm #15750Tom
KeymasterAh, 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?
May 20, 2020 at 3:04 pm #15754Bodie J
ParticipantI 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/
Thanks for your help!
May 21, 2020 at 3:39 pm #15797Tom
KeymasterAs 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 thetax_term
with the current term ID.May 21, 2020 at 5:42 pm #15801Bodie J
ParticipantThis 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 thetimeline_tag
and thetimeline_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
May 21, 2020 at 10:05 pm #15818Bodie J
ParticipantSorry 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!
May 22, 2020 at 4:26 pm #15850Tom
KeymasterThat 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?
-
AuthorPosts
- You must be logged in to reply to this topic.