- This topic has 7 replies, 2 voices, and was last updated 3 years, 2 months ago by
wensolutions.
- AuthorPosts
- March 16, 2020 at 10:43 pm #24654
joshk
ParticipantThe Trip search bar placeholder says “Ex: Trekking”.
How can we change that to something else?
We have a child theme and can place something in the functions.php file, if that helps.March 17, 2020 at 6:36 am #24662wensolutions
KeymasterHello @joshk,
Yes, you can definitely change the placeholder but for this, you need to activate your child theme.
To know how you can create and activate the child theme, please refer to below given link:
https://wptravel.io/how-to-create-a-child-theme/
After activating the child theme, in your child theme functions.php add below given code:
function wp_travel_modify_placeholder_text( $content ){ $label_string = apply_filters( 'wp_travel_search_filter_label_strings', array( 'search' => __( 'Search:', 'wp-travel' ), 'trip_type' => __( 'Trip Type:', 'wp-travel' ), 'location' => __( 'Location:', 'wp-travel' ), ) ); $search_string = ! empty( $label_string['search'] ) ? $label_string['search'] : ''; $trip_type_string = ! empty( $label_string['trip_type'] ) ? $label_string['trip_type'] : ''; $location_string = ! empty( $label_string['location'] ) ? $label_string['location'] : ''; ob_start(); ?> <div class="wp-travel-search"> <form method="get" name="wp-travel_search" action="<?php echo esc_url( home_url( '/' ) ); ?>" > <input type="hidden" name="post_type" value="<?php echo esc_attr( WP_TRAVEL_POST_TYPE ); ?>" /> <p> <label><?php echo esc_html( $search_string ); ?></label> <?php $placeholder = __( 'Your Text', 'wp-travel' ); ?> <input type="text" name="s" id="s" value="<?php echo ( isset( $_GET['s'] ) ) ? esc_textarea( $_GET['s'] ) : ''; ?>" placeholder="<?php echo esc_attr( apply_filters( 'wp_travel_search_placeholder', $placeholder ) ); ?>"> </p> <p> <label><?php echo esc_html( $trip_type_string ); ?></label> <?php $taxonomy = 'itinerary_types'; $args = array( 'show_option_all' => __( 'All', 'wp-travel' ), 'hide_empty' => 0, 'selected' => 1, 'hierarchical' => 1, 'name' => $taxonomy, 'class' => 'wp-travel-taxonomy', 'taxonomy' => $taxonomy, 'selected' => ( isset( $_GET[ $taxonomy ] ) ) ? esc_textarea( $_GET[ $taxonomy ] ) : 0, 'value_field' => 'slug', ); wp_dropdown_categories( $args, $taxonomy ); ?> </p> <p> <label><?php echo esc_html( $location_string ); ?></label> <?php $taxonomy = 'travel_locations'; $args = array( 'show_option_all' => __( 'All', 'wp-travel' ), 'hide_empty' => 0, 'selected' => 1, 'hierarchical' => 1, 'name' => $taxonomy, 'class' => 'wp-travel-taxonomy', 'taxonomy' => $taxonomy, 'selected' => ( isset( $_GET[ $taxonomy ] ) ) ? esc_textarea( $_GET[ $taxonomy ] ) : 0, 'value_field' => 'slug', ); wp_dropdown_categories( $args, $taxonomy ); ?> </p> <p class="wp-travel-search"><input type="submit" name="wp-travel_search" id="wp-travel-search" class="button button-primary" value="<?php esc_html_e( 'Search', 'wp-travel' ); ?>" /></p> </form> </div> <?php return ob_get_clean(); } add_filter('wp_travel_search_form','wp_travel_modify_placeholder_text');
Now, go line ” <?php $placeholder = __( ‘Your Text’, ‘wp-travel’ ); ?>” and change the text as per your requirment.
Hope this helps.
Thank you.
March 18, 2020 at 10:43 pm #24724joshk
ParticipantPerfect, thank you. It worked.
March 19, 2020 at 4:07 am #24729wensolutions
KeymasterHello @joshk,
Glad we could help you.
If you have any issues further then kindly let us know.
Thank you.
March 25, 2020 at 9:22 pm #24927joshk
ParticipantThis worked great, but then I realized that it does not allow me to translate the text in WPML string translation anymore.
If I set the placeholder to “Food”, it sets that as the placeholder for all languages and I cannot seem to access it inside of WPML string translation to translate it.
How do I get it to show up in WPML string translation so that I can translate it?
March 26, 2020 at 10:56 am #24933wensolutions
KeymasterHello @joshk,
The string that you have replaced should at first be scanned using the WPML plugin as it is newly added string in the plugin.
To scan the string you need to go to Admin Panel > WPML > Theme and Plugin Localization. Here find the text domain, click on the box and click on “Scan Selected theme For string” or “Scan Selected theme For string” button finding weather the string comes from the theme or the plugin originally.
Screenshot:
Hope this helps.
Thank you.
March 30, 2020 at 9:32 am #25010joshk
ParticipantExcellent, thank you! Worked perfectly.
March 31, 2020 at 3:24 am #25028wensolutions
Keymaster - AuthorPosts
- The forum ‘WP Travel Pro’ is closed to new topics and replies.