- This topic has 5 replies, 2 voices, and was last updated 2 years, 8 months ago by
Fernando.
-
AuthorPosts
-
January 10, 2023 at 12:35 pm #2490624
John
Hi,
I have a
provider
post type, with atype of services
taxonomy.I’m able to use GP/GB to create a loop showing each
provider
and show the list of terms for each provider. However, I have a lot of Providers and a more manageable number of Types of Services – obviously, the point of a taxonomy is to group items meaningfully together.So I don’t want to display the list of all Providers, instead I want to show the list of Services, each directing to a page where the Providers for that type of services are displayed.
Problem is, as obvious as the use case seems, I can’t find a way with GP or GB to simply show a list of taxonomy terms. Is it possible?
Thank you
January 10, 2023 at 9:30 pm #2490888Fernando Customer Support
Hi John,
It’s possible but doing it dynamically will require custom code.
Do you have a lot of terms for this custom taxonomy? If not, what I would suggest is to build the list from scratch so you can properly design it with GenerateBlocks.
If you have a lot, you can a shortcode to query them but you’ll need custom CSS to style this.
Sample Shortcode:
add_shortcode( 'my_shortcode', function() { ob_start(); // Start your PHP below $terms = get_terms( array( 'taxonomy' => 'your-taxonomy', 'hide_empty' => false, ) ); // Check if any term exists if ( ! empty( $terms ) && is_array( $terms ) ) { // Run a loop and print them all foreach ( $terms as $term ) { ?> <a href="<?php echo esc_url( get_term_link( $term ) ) ?>"> <?php echo $term->name; ?> </a><?php } } // End your PHP above return ob_get_clean(); } );
Replace
your-taxonomy
with your taxonomy slug.Creating it through GenerateBlocks manually would be an easier approach design-wise.
January 10, 2023 at 9:35 pm #2490890John
Thanks Fernando. I was indeed hoping to get the best of both worlds: generate the list dynamically and style it with GenerateBlocks, similarly to a GB Query Loop. I do need to design it, include the term description, etc.
I don’t have many terms right now, but this will change so I wanted to avoid doing it manually as much as possible. But the shortcode option doesn’t really suit me, so I will have to go with manual…
Is there any plan to include this feature in GB (Pro) going forward? I was hoping that when defining a Query Loop, I would simply choose “Taxonomy” instead of “Post” type.
January 10, 2023 at 10:21 pm #2490911Fernando Customer Support
There’s no plan yet for such a feature in the upcoming update. You can raise a feature request here though: https://community.generateblocks.com/c/feature-requests/6
Perhaps there’s a third-party plugin for such a feature as well. It may be good to ask for recommendations from our Facebook Page as well: https://www.facebook.com/groups/1113359788719597
You’re welcome, John!
January 10, 2023 at 11:44 pm #2490949John
Ok thank you. Too bad, that’d be very useful. I submitted a feature request.
January 11, 2023 at 12:53 am #2490995Fernando Customer Support
You’re welcome, John!
-
AuthorPosts
- You must be logged in to reply to this topic.