Home › Forums › Calendar Products › Events Calendar PRO › Modifying tribe_meta_event_cats() output
- This topic has 18 replies, 5 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
December 1, 2011 at 7:54 pm #11634
Joe
MemberHi 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 #11635Joe
MemberWell, 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 #11662Rob
MemberSorry 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 #11686Jonah
ParticipantHi 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 #11694Joe
MemberThanks 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 #11842Jonah
ParticipantHi 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 #11843Joe
MemberThanks 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 #11845Jonah
ParticipantTry this: http://pastebin.com/gYTNTW0E
December 5, 2011 at 12:49 pm #11848Joe
MemberThat’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 #11849Jonah
ParticipantTry changing the $args variable to:
$args = array( 'taxomomy'=>'sp_events_cat','orderby' => 'slug' );
December 5, 2011 at 1:05 pm #11852Joe
MemberNo luck. Does get_the_ID() need to go anywhere?
December 5, 2011 at 2:22 pm #11853Jonah
ParticipantNo 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 #11855Joe
MemberStill 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 #11857Joe
MemberSorry, guess there’s a reason why pastebin is preferred:
http://pastebin.com/ZiMD3gwtDecember 6, 2011 at 11:03 am #11899Joe
MemberThat works perfectly. Thanks again for the great support on this!
-
AuthorPosts
- The topic ‘Modifying tribe_meta_event_cats() output’ is closed to new replies.
