Make All Events link go to Category

Home Forums Calendar Products Filter Bar Make All Events link go to Category

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1012038
    Sean
    Participant

    Hi,

    I am basically trying to do what this person asked: https://theeventscalendar.com/support/forums/topic/all-events-link/ I have the template file open and understand where to edit the code, but I can’t figure out the correct code. I need to replace this:

    	<p class="tribe-events-back">
    		<a href="<?php echo esc_url( tribe_get_events_link() ); ?>"> <?php printf( __( '&laquo; All %s', 'the-events-calendar' ), $events_label_plural ); ?></a>
    	</p>

    With?

    Thank you!

    #1012193
    George
    Participant

    Hey Sean,

    We don’t officially offer any support for custom code, but I’m happy to help here because this should be a fairly simple, straightforward tweak to make. You should be able to use the same function that Casey recommended in the original thread you linked to: get_term_link().

    His example was as follows:

    <a href="<?php echo esc_url( get_term_link( $your_category_id, 'tribe_events_cat' ) ); ?>">

    Replace the variable $your_category_id with the ID of the events category you would like to link to. You can find the category ID by going into your admin and going to Events > Event Categories, then hover your mouse over the category you would like to link to.

    When hovering over the category, the URL in the bottom of the browser should have a parameter in it like &tag_ID=4 or something. This number is the category ID. Check out this screenshot for example, and see the URL in the bottom left as I hover over the “Concert” category name:

    I hope this helps – best of luck with your customizations!

    — George

    #1012363
    Sean
    Participant

    I still don’t understand, if you can please help. I don’t see any reference in documentation for get_term_link or tribe_events_cat. I replaced the code with:

    <a href="<?php echo esc_url( get_term_link( 6, 'tribe_events_cat' ) ); ?>"> <?php printf( __( '&laquo; All %s', 'the-events-calendar' ), $events_label_plural ); ?></a>

    This changed the All Events to a specific category, which is ok, but I need the category to display just as the same in Event category in details:

    http://prntscr.com/8ornyi

    Can you tell me how to pull the category of the event being displayed? I figured it would be in the single-event.php page already, but can’t seem to find it in the code.

    #1013151
    George
    Participant

    Hey Sean,

    We don’t offer any support for custom code, so unfortunately I cannot lay out the code for how to get everything working and looking as you hope. One thing you asked, however, is this:

    Can you tell me how to pull the category of the event being displayed?

    Do you mean that you want to get the categories for the currently-viewed event? This seems to be the case based on your comment about already having tried looking in single-event.php…

    Assuming this is what you mean, then getting the category or categories for the currently-viewed event is possible with built-in WordPress function get_the_ID(). This does the magic of getting the Post ID for the currently-viewed item; so in the context of events, for example, just use this function and the tribe_get_event_categories() function together like this:


    tribe_get_event_categories( get_the_ID() );

    If you want to learn more about this function, check it out in the plugin directly here: the-events-calendar/src/functions/template-tags/general.php

    Best of luck with your customizations!

    — George

    #1014041
    Sean
    Participant

    This reply is private.

    #1014169
    George
    Participant

    Hm, this is an odd character to appear because it’s just floating on your page in a “div” HTML tag, with no classes or IDs or anything like that…weird!

    But yes, you should be able to hide that by adding the following CSS to the bottom of your theme’s style.css file:


    body.single-tribe_events #tribe-events-content > div:first-of-type {
    display: none;
    }

    Let me know if that helps!
    George

    #1019286
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Make All Events link go to Category’ is closed to new replies.