show category in event title

Home Forums Ticket Products Event Tickets Plus show category in event title

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1160417
    Pau
    Participant

    Dear TECPRO,

    I would like to show the category (and category colour) on the Event Title

    Currently, I’m showing title / date / venue / city

    I would like to add category

    I know I have to edit all the php files and so, the question is: which snippet of code do I need to use to ‘call’ the category?

    many thanks as usual

    #1160430
    Geoff
    Member

    Hey Pau, nice to see you and I hope all is well .:)

    We actually have a post that provides step-by-step instructions for adding the category of an event to the event title:

    https://theeventscalendar.com/knowledgebase/add-category-prefix-to-event-titles/

    Try using that and see if it at least helps get you started. πŸ™‚

    Cheers!
    Geoff

    #1160510
    Pau
    Participant

    Hi Geoff, how are you?

    This is great, exactly what I need

    Unfortunately, either I paste this on the wrong place or the code is not good

    it comes with an error, and when tried the site crashed (I did back up, so all saved again)

    This is the code:

    <?php
    // Prepends category name(s) to the event titles
    function tribe_events_title_include_cat ($title, $id) {
    	$separator = ' &raquo; '; // HTML Separator between categories and title
    	$cats = get_the_terms($id, 'tribe_events_cat');
    	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
    	$is_truly_admin = is_admin() && !$is_ajax;
    	if (tribe_is_event($id) && $cats && !is_single() && !$is_truly_admin) {
    		$cat_titles = array();
    		foreach($cats as $i) {
    			$cat_titles[] = $i->name;
    		}
    		$title = implode(', ', $cat_titles) . $separator . $title;
    	}
    	return $title;
    }
    add_filter('the_title', 'tribe_events_title_include_cat', 100, 2);

    on Dreamweaver (yes, I know!) says 1st line is wrong…

    any suggestions ( or how should i paste this on the functions.php?

    Thanks for patience again
    πŸ™‚

    #1160705
    Geoff
    Member

    Oh shoot so sorry about that Pau!

    Will you please try removing the first line from the snippet? That <?php code may not be necessary in theΒ functions.php file.

    Thanks!
    Geoff

    p.s. No hate on dreamweaver! In fact, the preview of the next release looks pretty sweet. πŸ™‚

    #1160721
    Pau
    Participant

    Oh, the joy!
    thanks
    x

    #1160894
    Geoff
    Member

    My pleasure! Have a great day. πŸ™‚

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘show category in event title’ is closed to new replies.