- This topic has 24 replies, 3 voices, and was last updated 4 years, 5 months ago by
Elvin.
-
AuthorPosts
-
December 7, 2021 at 11:28 pm #2042012
Elvin
StaffCustomer SupportAh I see what you mean.
Can you tell us how and where you want it to be displayed?
Do you want it to appear on the Header Element? If that’s the case, you’ll need a shortcode to display the taxonomy term links.
We can write a quick shortcode for this if this is the case. Let us know.
December 8, 2021 at 5:24 am #2042276Hilton
This is the place I want to be displayed (after the content).
https://bit.ly/3dsK9X3The same place as regular posts https://bit.ly/3dtYTVs
Thanks
December 8, 2021 at 5:36 am #2042286Hilton
One more thing, regarding placement, I don’t think you need to worry because we can hook it using GP’s “Elements” like we did here (generate_after_content) Elements: https://bit.ly/3Iwdv4R frontend: https://bit.ly/31BVyRx
Thanks
December 8, 2021 at 5:34 pm #2043022Elvin
StaffCustomer SupportAh yes that’s right.
In that case, I think what you need is the shortcode now.
Try Tom’s shortcode here – https://generatepress.com/forums/topic/help-with-template-tags-for-custom-post-type/#post-1540350
for the term attribute, place the slug of your custom category.
December 8, 2021 at 6:03 pm #2043034Hilton
Hi Elvin,
It worked, the categories are being displayed. But the links are not active as you can see here https://bit.ly/31BVyRx . How can I activate the respective links?
Thanks
December 8, 2021 at 6:25 pm #2043040Elvin
StaffCustomer Supportah right, the shortcode specifically strips the link.
Let’s modify the shortcode a bit:
Try this modification:
add_shortcode( 'my_terms', function( $atts ) { $options = shortcode_atts( array( 'term' => 'category', ), $atts ); $terms = get_the_term_list( get_the_ID(), $options['term'], '', ', ', '' ); if ( ! is_wp_error( $terms ) ) { return $terms; } } );December 8, 2021 at 6:35 pm #2043045Hilton
Now it worked! The only pending issue is to put it in the same format as the normal posts as you can see here in this print https://bit.ly/3IqVp4i and in this post for example https://bit.ly/3lNnZDv .
I think it uses the <span class=”cat-links”>
Thanks
December 8, 2021 at 6:46 pm #2043049Elvin
StaffCustomer SupportWe can modify it further to wrap it in that element.
Example:
add_shortcode( 'my_terms', function( $atts ) { $options = shortcode_atts( array( 'term' => 'category', ), $atts ); $terms = get_the_term_list( get_the_ID(), $options['term'], '', ', ', '' ); if ( ! is_wp_error( $terms ) ) { return sprintf( '<span class="cat-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ', esc_html_x( 'Categories', 'Used before category names.', 'generatepress' ), $terms, apply_filters( 'generate_inside_post_meta_item_output', '', 'categories' ) ); } } );I’ve included the icon as well.
December 8, 2021 at 7:22 pm #2043066Hilton
Elvin, thank you very much! It worked here. Excellent!
December 8, 2021 at 7:25 pm #2043068Elvin
StaffCustomer SupportNo problem. Let us know if this is resolved or if you need further help. 😀
-
AuthorPosts
- You must be logged in to reply to this topic.