• Resolved Luis Martins

    (@lmartins)


    Hi,

    I have a WP site setup with pt_PT language on the front-end. Everything is ok on the backend but on the front-end the WP default widget won’t get translated.

    Looked everywhere but I can’t find a way to translate the input placeholder and the text on the submit button. Any tips?

Viewing 1 replies (of 1 total)
  • Thread Starter Luis Martins

    (@lmartins)

    Found a solution. Mind you the code bellow is for the Genesis framework, so you might need to adapt it to the default WordPress hooks.

    You need to filter the labels and pass them through a translation function, as shown bellow:

    /**
     * Customize the search form input box text
     *
     * See: https://www.briangardner.com/code/customize-search-form/
     *
     * @since 2.0.0
     */
    add_filter( 'genesis_search_text', 'bfg_search_text' );
    function bfg_search_text() {
    
        return esc_attr__( 'Search in this Website...', 'webipack' );
    
    }
    
    /**
     * Customize the search form input button text
     *
     * See: https://www.briangardner.com/code/customize-search-form/
     *
     * @since 2.0.0
     */
    add_filter( 'genesis_search_button_text', 'bfg_search_button_text' );
    function bfg_search_button_text( $text ) {
    
        return esc_attr__( 'Search', 'webipack' );
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Default Search Widget not picking up translation’ is closed to new replies.