Home › Forums › Calendar Products › Events Calendar PRO › Modifying tribe_meta_event_cats() output
- This topic has 18 replies, 5 voices, and was last updated 8 years, 10 months ago by Support Droid.
-
AuthorPosts
-
December 1, 2011 at 7:54 pm #11634JoeMember
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!December 1, 2011 at 7:56 pm #11635JoeMemberWell, 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]
December 2, 2011 at 10:08 am #11662RobMemberSorry 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.
December 2, 2011 at 5:28 pm #11686JonahParticipantHi 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,
JonahDecember 3, 2011 at 5:34 am #11694JoeMemberThanks 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.December 5, 2011 at 8:27 am #11842JonahParticipantHi 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,
JonahDecember 5, 2011 at 8:31 am #11843JoeMemberThanks Jonah, I’ll take a look at that. How can I output the category slug to give each link its own unique class?
December 5, 2011 at 9:02 am #11845JonahParticipantTry this: http://pastebin.com/gYTNTW0E
December 5, 2011 at 12:49 pm #11848JoeMemberThat’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.
December 5, 2011 at 12:56 pm #11849JonahParticipantTry changing the $args variable to:
$args = array( 'taxomomy'=>'sp_events_cat','orderby' => 'slug' );
December 5, 2011 at 1:05 pm #11852JoeMemberNo luck. Does get_the_ID() need to go anywhere?
December 5, 2011 at 2:22 pm #11853JonahParticipantNo 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.
December 5, 2011 at 3:17 pm #11855JoeMemberStill 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 '';
}}
December 5, 2011 at 3:19 pm #11857JoeMemberSorry, guess there’s a reason why pastebin is preferred:
http://pastebin.com/ZiMD3gwtDecember 6, 2011 at 11:03 am #11899JoeMemberThat works perfectly. Thanks again for the great support on this!
-
AuthorPosts
- The topic ‘Modifying tribe_meta_event_cats() output’ is closed to new replies.