Is it possible to use custom taxonomies?

Home Forums Welcome! Pre-Sales Questions Is it possible to use custom taxonomies?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1084097
    Chris
    Guest

    I’m looking to create a calendar for conventions and I’d like to have a custom taxonomy for speakers at the event(like the category taxonomy used for each event post). I’d like these to show up as a clickable link in the event post so that if you click on someone’s name it will show you all events that they will be speaking at. I thought the custom fields part of pro would do this but it seems you’d have to add the link manually. This would be more like a tag or a category in a normal post.

    #1084413
    George
    Participant

    Hey Chris,

    Thanks for reaching out. If you have custom taxonomies within your site, you can add them to custom post types with the WordPress function register_taxonomy_for_object_type().

    That will require adding some custom code, like to your theme’s functions.php file for example, but it’s a rather simple customization to make. You can learn more about that function here → http://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type

    If you have two custom taxonomies called “chris_category” and “chris_tag”, for example, you could add both to the Events post type by adding this snippet to your theme’s functions.php file:


    register_taxonomy_for_object_type( 'chris_category', 'tribe_events' );
    register_taxonomy_for_object_type( 'chris_tag', 'tribe_events' );

    I hope this helps!

    — George

    #1084477
    Chris
    Guest

    I don’t have any custom taxonomies yet. I’m researching plugins to use for my calendar and I like yours so far, but I’m trying to figure some stuff out before I order the pro version.

    With the option you provided, would that show the selected taxonomy in a post and have each be a clickable link to go to all events they’re featured in? It’s difficult to explain, so hopefully I’m doing a decent job.

    I’m using a different plugin now, but it’s not meeting all of my needs. You can see an example here:

    http://www.findacomiccon.com/events/emerald-city-comicon-seattle-wa/

    Under “Who Will Be At Comic Con?”, each category is a custom taxonomy in the calendar plugin. If you click a name, it will show you every even they’ll be at.

    #1084569
    George
    Participant

    Hi Chris,

    The method I described adds an existing custom taxonomy to events. So, yes, if this taxonomy’s settings include archive links then there will be archives you can go to for the taxonomy etc. To get things functioning just right, it again might take some code tinkering, but yes by default it should work as you describe.

    Will it display as you describe? A list of links on the single event like in your example, by default?

    No.

    To get the custom taxonomies to display as a linked list on single-events templates, you would need to customize The Events Calendar’s single-event template to include a custom call to load the taxonomies. You can learn how to do this here → https://theeventscalendar.com/knowledgebase/themers-guide/

    An even simpler approach would be to use the hook tribe_events_single_event_after_the_meta to add content after the single-event meta section (or tribe_events_single_event_before_the_meta to add content before the single-event meta section).

    You can then use the wp_list_categories() function to simply echo a list of taxonomy links, which you can learn more about here → https://codex.wordpress.org/Template_Tags/wp_list_categories

    If the custom taxonomy whose list of items you were echoing was called tribe_events_cat, for example, then you could put all of this code together to add something like this to your theme’s functions.php file:


    add_action( 'tribe_events_single_event_after_the_meta', 'tribe_custom_single_event_tax' );

    function tribe_custom_single_event_tax() {

    wp_list_categories( array(
    'title_li' => 'Custom Taxonomy Test',
    'taxonomy' => 'tribe_events_cat'
    ) );
    }

    Here’s a screenshot of how that looks:

    You’d have to take the reins from here to style it how you’d like and all of that, but I hope all of this helps.

    George

    #1085222
    Chris
    Guest

    Thank you!

    #1085995
    George
    Participant

    No problem! 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Is it possible to use custom taxonomies?’ is closed to new replies.