Change all labels in tribe search bar

Home Forums Calendar Products Events Calendar PRO Change all labels in tribe search bar

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1420996
    Daniel Gray
    Participant

    The 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,
    Mike

    #1422140
    Andras
    Keymaster

    Hi 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,
    Andras

    #1422905
    Daniel Gray
    Participant

    Hello 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 name

    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;
    

    }`

    • 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.
    #1422917
    Daniel Gray
    Participant

    Worked 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;
    }

    #1423337
    Andras
    Keymaster

    Looks 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

    #1424036
    Daniel Gray
    Participant

    I 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.

    #1424487
    Andras
    Keymaster

    Hi 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,
    Andras

    #1424848
    Daniel Gray
    Participant

    Can you point me the right directions as to what functions I may need to accomplish this?

    #1426737
    Andras
    Keymaster

    Hi 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,
    Andras

    #1445230
    Support Droid
    Keymaster

    Hey 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

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Change all labels in tribe search bar’ is closed to new replies.