Home › Forums › Calendar Products › Events Calendar PRO › Change all labels in tribe search bar
- This topic has 10 replies, 2 voices, and was last updated 8 years, 3 months ago by
Daniel Gray.
-
AuthorPosts
-
January 8, 2018 at 7:27 pm #1420996
Daniel Gray
ParticipantThe labels in the search bar by default are named “Events From”, “Near”, “Search” and the “Find Events” button.
The goal is to rename the labels based on category.
Here is the code I am using to change them. The only two fields I was able to name successfully are the “Near” and “Search” fields.
Here is the function I am using in functions.php
`add_filter(‘gettext’, ‘theme_filter_text’, 10, 3);function theme_filter_text( $translations, $text, $domain ) {
$cat_type = evnt_name(2);
$passthrough = $text;
// Copy and modify the following if {} statement to replace multiple blocks of text
// Match the text you want you want to translate, preferably also match the text domain
if($text === ‘Events From’ && $domain === ‘tribe-events-calendar’) {
// The custom text you want instead
$text = $cat_type.’ from’;
}
if($text === ‘Near’ && $domain === ‘tribe-events-calendar-pro’) {
// The custom text you want instead
$text = ‘City, State or zip’;
}
if($text === ‘Search’ && $domain === ‘tribe-events-calendar’) {
// The custom text you want instead
if($cat_type === “Classes”){
$cat_type = “Class”;
}
$text = ‘Type of ‘.$cat_type;
}
if($text === ‘Find Events’ && $domain === ‘tribe-events-calendar’) {
// The custom text you want instead
$text = ‘Find ‘.$cat_type;
}return $text;}
`I am unable to get “Events From” and the “Find Events” text changed.
The page I am working on is
http://www.fitboxworld.com/find-an-event/Thank you,
MikeJanuary 10, 2018 at 1:21 am #1422140Andras
KeymasterHi Mike,
That looks like a great customization you are trying to do there. Would love to see that in action once it’s done.
The strings are a bit different for those two.
Try using “%s From” instead of “Events From” and
“Find %s” instead of “Find Events”.
Let me know if that does the trick.
Cheers,
AndrasJanuary 10, 2018 at 12:15 pm #1422905Daniel Gray
ParticipantHello AndrĂ¡s,
Worked like a charm.
Here is the finished code along with the evnt_name() function in case it will help others:`// Return event category name
function evnt_name($depth){
$cat = get_queried_object();
$cat_type = $cat->name;
return $cat_type;
}
add_filter(‘gettext’, ‘theme_filter_text’, 10, 3);function theme_filter_text( $translations, $text, $domain ) {
$cat_type = evnt_name(2); // event category nameif($text === '%s From' && $domain === 'the-events-calendar') { // The custom text you want instead $text = $cat_type.' from'; } if($text === 'Near' && $domain === 'tribe-events-calendar-pro') { // The custom text you want instead $text = 'City, State or zip'; } if($text === 'Search' && $domain === 'tribe-events-calendar') { // The custom text you want instead if($cat_type === "Classes"){ $cat_type = "Class"; } $text = 'Type of '.$cat_type; } if($text === 'Find %s' && $domain === 'the-events-calendar') { // The custom text you want instead $text = 'Find '.$cat_type; } return $text;}`
-
This reply was modified 8 years, 4 months ago by
Daniel Gray.
-
This reply was modified 8 years, 4 months ago by
Daniel Gray.
-
This reply was modified 8 years, 4 months ago by
Leah.
January 10, 2018 at 12:19 pm #1422917Daniel Gray
ParticipantWorked like a charm.
Here is the complete code:
// Return event category name
function evnt_name($depth){
$cat = get_queried_object();
$cat_type = $cat->name;
return $cat_type;
}// Translate labels in Events Calendar Pro search bar
add_filter('gettext', 'theme_filter_text', 10, 3);function theme_filter_text( $translations, $text, $domain ) {
$cat_type = evnt_name(2); // event category name
// Copy and modify the following if {} statement to replace multiple blocks of text
// Match the text you want you want to translate, preferably also match the text domain
//echo "testing:".$text;
if($text === '%s From' && $domain === 'the-events-calendar') {
// The custom text you want instead
$text = $cat_type.' from';
}
if($text === 'Near' && $domain === 'tribe-events-calendar-pro') {
// The custom text you want instead
$text = 'City, State or zip';
}
if($text === 'Search' && $domain === 'tribe-events-calendar') {
// The custom text you want instead
if($cat_type === "Classes"){
$cat_type = "Class";
}
$text = 'Type of '.$cat_type;
}
if($text === 'Find %s' && $domain === 'the-events-calendar') {
// The custom text you want instead
$text = 'Find '.$cat_type;
}
return $text;
}
January 11, 2018 at 2:39 am #1423337Andras
KeymasterLooks awesome Daniel! Thanks for sharing!
Happy I could help you to make this work.
Is there anything else I can help you with or can we close this as resolved?
Andras
January 11, 2018 at 12:50 pm #1424036Daniel Gray
ParticipantI have a seperate question:
I am using some custom code located on github here: https://github.com/bordoni/tec-forum-support/blob/plugin-949602/plugin.php
This displays the drop down on all three pages.
I need this to be dynamic where it pulls sub-categories from main category.Example
Classes Page: http://www.fitboxworld.com/find-a-class/Classes //main cat
– ALL // list all sub categories
– FITBOX // sub
– EXTREME // sub
– …..Events Page: http://www.fitboxworld.com/find-an-event/
Events //main cat
– ALL // list all sub categories
– FITBOXATHON
– …Trainings Page: http://www.fitboxworld.com/find-a-training/
Trainings // main
– ALL // list all sub categories
– FITBOX
– ADVANCED
– ….Thanks.
January 12, 2018 at 3:16 am #1424487Andras
KeymasterHi Daniel,
Doing and supporting customizations of this kind is beyond the scope of our support, I’m sorry.
If you need help in further customizing that snippet or developing a new one then I can share with you this list of freelance developers who are well known in our community and are not affiliated with us. They will be able to help you out.
Cheers,
AndrasJanuary 12, 2018 at 8:59 am #1424848Daniel Gray
ParticipantCan you point me the right directions as to what functions I may need to accomplish this?
January 15, 2018 at 11:23 am #1426737Andras
KeymasterHi Daniel,
I need to ask around a bit as this is beyond me. Most of it I believe can be done with WP functions.
Give me some time to check around and I’ll get back to you in a day or two. Thanks for your patience!
Cheers,
AndrasFebruary 6, 2018 at 8:36 am #1445230Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
This reply was modified 8 years, 4 months ago by
-
AuthorPosts
- The topic ‘Change all labels in tribe search bar’ is closed to new replies.
