Change label in search bar

Home Forums Calendar Products Events Calendar PRO Change label in search bar

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1176207
    Kate
    Participant

    I am trying to change the label in the search bar from “Search” to “Contains the word or name:”. I am following instructions found in other threads and added this snippet to my theme’s functions.php file:

    // Translate labels in Events Calendar Pro search bar 
    
    add_filter('gettext', 'theme_filter_text', 10, 3);
    
    function theme_filter_text( $translations, $text, $domain ) {
     
    	// 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 === 'Search' && $domain === 'tribe-events-calendar') {
    
    		// The custom text you want instead
                    $text = 'Contains the word or name:';
    
            }
     
            return $text;
    }

    It’s not having any effect. Does it belong in functions.php? Is the domain ‘tribe-events-calendar’ correct even if I am using the Events Calendar Pro? I have double checked the capitalization of the term I want to replace and it’s accurate. Thanks for any additional guidance you can offer.

    #1176305
    Cliff
    Member

    Hi Kate.

    Could you please specify which of the 2 “search” words you’re trying to alter — https://cl.ly/0e1r3L292b0i — #1 or #2 or both?

    #1176732
    Kate
    Participant

    #1. The label, not the placeholder. Thanks!

    #1176880
    Cliff
    Member

    Kate, that “Search” text is coming from this code: https://github.com/moderntribe/the-events-calendar/blob/4.3/src/Tribe/Main.php#L4437

    Therefore, I believe your code is probably correct except for this part: domain === 'tribe-events-calendar'

    It should be “the-events-calendar”, not “tribe-events-calendar”.

    Please reference the current version of this code snippet at the end of this KB article: Change the wording of any bit of text or string

    Thanks!

    #1179850
    Kate
    Participant

    Cliff, neither blocks of code (old or new) had any effect on my site. I edited the src file and that effected a change. But I need to find an update-safe way to make this same change. Can it only be made in functions.php, or is it possible to have a child copy of main.php in the theme’s custom tribe-events directory?

    #1180009
    Cliff
    Member

    Please provide me the code snippet you currently have in your active theme’s functions.php?

    (And, no, Main.php isn’t able to be overridden like that because it’s not a template/output file.)

    #1190920
    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 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Change label in search bar’ is closed to new replies.