Modifying tribe_meta_event_cats() output

Home Forums Calendar Products Events Calendar PRO Modifying tribe_meta_event_cats() output

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #11634
    Joe
    Member

    Hi there,
    I’m trying to customize the output of single.php, and I was wondering how to change the output of the tribe_meta_event_cats() function. By default it outputs a and tag with the category links in alphabetical order, separated by a comma. I would like to modify it to do something like [category-name] for each. Can you point me in the right direction? Thanks!

    #11635
    Joe
    Member

    Well, guess I can’t use HTML tags. The output I’m trying to achieve is [a href=”{link to category}” class=”{category slug}”][span]{category name}[/span][/a]

    #11662
    Rob
    Member

    Sorry about the lack of HTML tags in the forum…we’re working to change that. I’ll get our dev Jonah to respond as to your initial request.

    #11686
    Jonah
    Participant

    Hi Joe,

    Unfortunately this is not possible without modifying the core code at this time. We are looking into things like this to make everything more editable and will take it into consideration.

    If you want to modify the core code (your changes will be overwritten the next time you update) you will want to modify /plugins/the-events-calendar/public/template-tags/general.php – line 102.

    Regards,
    Jonah

    #11694
    Joe
    Member

    Thanks Jonah, that’s what I figured. Would you mind helping me with the particular format I was trying to achieve? The tribe_meta_event_cats() function will let me change the [dt] and [dd] tags surrounding the category links, but I’m trying to edit the output of the link itself, which doesn’t seem to be set in that function. Instead of the current
    [a href=”$categorylink” rel=”tag”]$categoryname[/a]
    I’m trying to change it to
    {a href=”$categorylink” class=”events-$categoryslug” rel=”tag”][span]$categoryname[/span][/a]
    I don’t know where to find this, or how to call the category slug.

    #11842
    Jonah
    Participant

    Hi Joe,

    To modify the actual links you’ll have to change the tribe_meta_event_cats function to use get_terms instead of the_terms and modify the output accordingly: http://codex.wordpress.org/Function_Reference/get_terms

    Again, by modifying the core code your changes will be wiped out when you update unless you keep a catalog of your core changes and reintroduce after updating.

    You might try modifying the links via jQuery instead for now although it would be difficult to dynamically pull in the category info for each link.

    Regards,
    Jonah

    #11843
    Joe
    Member

    Thanks Jonah, I’ll take a look at that. How can I output the category slug to give each link its own unique class?

    #11845
    Jonah
    Participant
    #11848
    Joe
    Member

    That’s awesome, thank you Jonah! One thing though: it looks like that creates a link for every category in the system, instead of just the categories for that particular event.

    #11849
    Jonah
    Participant

    Try changing the $args variable to:


    $args = array( 'taxomomy'=>'sp_events_cat','orderby' => 'slug' );

    #11852
    Joe
    Member

    No luck. Does get_the_ID() need to go anywhere?

    #11853
    Jonah
    Participant

    No I don’ think so. What about if you use this:


    $args = array( 'orderby' => 'slug' );
    $terms = get_terms('sp_events_cat', $args);

    I’m not seeing the rest of my categories in the list and actually get_terms doesn’t get categories, it gets taxonomy terms… By putting ‘sp_events_cat’ as the first parameter this should tell get_terms to only get terms from that tax.

    #11855
    Joe
    Member

    Still outputting links to all categories in the system. :/ Just to confirm, here’s the full function:

    function tribe_meta_event_cats( $label=null, $separator=', ') {
    if( !$label ) { $label = __('Category:', 'tribe-events-calendar'); }

    $tribe_ecp = TribeEvents::instance();
    //the_terms( get_the_ID(), $tribe_ecp->get_event_taxonomy(), ''.$label.'', $separator, '' );

    $args = array( 'orderby' => 'slug' );

    $terms = get_terms($tribe_ecp->get_event_taxonomy(), $args);

    $count = count($terms); $i=0;
    if ($count > 0) {
    echo '' . $label . '';
    echo '';
    foreach ($terms as $term) {
    $i++;
    $term_list .= 'slug . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '" class="' . $term->slug . '">' . $term->name . ', ';
    }
    echo $term_list;
    echo '';
    }

    }

    #11857
    Joe
    Member

    Sorry, guess there’s a reason why pastebin is preferred:
    http://pastebin.com/ZiMD3gwt

    #11899
    Joe
    Member

    That works perfectly. Thanks again for the great support on this!

Viewing 15 posts - 1 through 15 (of 19 total)
  • The topic ‘Modifying tribe_meta_event_cats() output’ is closed to new replies.