Skip Navigation
availability:

WPML Version: 3.2

description:

Echoes an HTML hidden input field with name=”lang” and as value the current language.

In order to add a search form to your theme you would normally use the standard WordPress template tag: get_search_form()
If you are making use of the default WordPress search form, you do not need to edit anything. WPML will handle the rest.

However, there may be times when get_search_form() can’t be used. If you are creating a custom search form and you need to make it WPML compatible then this action hook is what you need.

type:
action
category:
Site-Wide Language Information
parameters:
do_action( 'wpml_add_language_form_field' )

This action hook does not have any parameters.

hook example usage:

Add the code below inside your search form code.

Example

// Return the HTML code for the current language Spanish
// <input type='hidden' name='lang' value='es' />
do_action( 'wpml_add_language_form_field' );