If you want to get the language of the browser do so:
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
If you want to redirect to ?lang=en:
header("location: {$_SERVER['REQUEST_URI']}?lang={$lang}");
You should read about HTTP_ACCEPT_LANGAUGE.
There are many ways you can dance with languages but you should understand some key points.
- Chose the default language of your website (French in your case)
- The user may be French but his OS & Browser can be in English because he wants to learn the language of trade.
- Create a cookie that stores the selected (or default) language so that you know what content to display.
$_COOKIE["wpse_166976_lang"] = "fr"or$_COOKIE["wpse_166976_lang"] = $landwhere$lang = get_query_var("lang")
To get the language with WPML plugin, you could use ICL_LANGUAGE_CODE to get the language of the page
Related Posts:
- Show the most popular post per week
- why is translation not working on theme?
- How to change date language without changing the entire site language?
- Filter the blog title displayed in the header
- How to change
- php syntax – how to concatenate properly – echo bloginfo(‘stylesheet_directory)
- How to let users change site language?
- Non-Closing PHP Query in WordPress Loop
- Split site title and apply different classes
- Using bloginfo and divs inside a php file
- WordPress language switcher doesn’t work
- Changing wordpress default language
- How to set base url for php widget
- CSS images don’t show up with bloginfo
- Implementing a multilingual WordPress site by installing several instances of WordPress and redirecting
- I have a background-image in css file but don’t show in site.how to fix this prblm. i sent screenshot. thx
- Change WooCommerce currency programmatically on AJAX request
- How to display dual language menus and headers?
- How to Get Linked Elements for a specific ml_source_elementid
- Conditionally change WordPress core language
- Multilanguage website on two different domains
- How can I include a file related to blog URL? Nothing seems to work
- WPMU – How to echo only one URL
- How to translate the blog date in the Avada theme [closed]
- make my custom theme support polylang plugin
- What is the correct way to use WordPress functions outside WordPress files?
- WP-CLI – Selecting PHP version
- Hide php Notices in Dashboard
- Shortcode to insert
- WordPress new user / forgot password emails are broken
- How to get year, month and hour in WordPress?
- Calling a method from functions.php on a click of a button
- Specified file failed upload test. wp_upload_handle
- Want to separate sections of posts. Can you restart loop?
- How to change featured content to a different tag in WordPress Twenty Fourteen?
- How do I create comment-reply-button using element not
- Two posts in same div – WP loop
- Compare two meta key values against each other inside the get_posts array?
- Removing WordPress profile fields from non-admins
- WordPress menu deletes when trying to add a hook
- Issue with foreach on duplicate meta_key’s
- Why am I getting ERR_NAME_NOT_RESOLVED when I add a site to my multisite installation? [closed]
- How to display custom field on homepage
- Show custom field if it exists, and show different elements if it doesn’t
- Making Quote Plugin more efficient
- Different database query in function.php using mysqli
- Create shortcodes within foreach loop (using array)
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- Passing UTM Parameters To Modify Page In WordPress
- How can I get the values of my WordPress $wpdb query in Jquery?
- Exclude category
- how much php coding do i need to know in order to create web blog using wordpress.org
- WordPress wp_add_inline_style unable to give hex colors?
- Parse error: syntax error, unexpected end of file
- How would I use this filter to change the output of the date format to “Twitter time”?
- WP Business Directory Manager Plugin Admin Listings?
- wordpress admin plugin menu custom css
- How to append to an array and return the results in a filter?
- Generating rel=”prev” and rel=”next” using filters
- Why i can’t get custom fields value or post ID via Ajax?
- Fatal errors to undefined function in theme 404.php file [closed]
- the_meta – no get_the_meta query?
- Get value from db for custom contact form
- WordPress: Displaying all the post tags from within a specific taxonomy’s term
- how to insert content into my taxonomy
- WP insert post Redirect after function has executed
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- add_action in namespace not working
- Using a new WP_Query inside the loop
- How to Send Pingbacks for all Posts in WordPress?
- Has a PHP update given me a 404?
- Replace background image with post thumbnail in shortcode
- Using A PHP App in WordPress
- HTML comment cause issue in functions.php script root
- Custom User registration system
- Rewrite rule not working, but only when parameter is text
- How to prevent adding data to a localhost database after refresh?
- wp_ajax_ 400 Bad Request
- WordPress Ajax filter: Create two loops for different output styles?
- How to display sticky post always at the top (before regular post) in wordpress?
- PHP warning with code for nav menu walker [duplicate]
- Get the image title and alt from custom query
- Showing wordpress latest post thumbnails in slider with auto increment
- media_handle_upload fails with gravity form submitted image
- how to display woocomerce description of each category in wordpress? [closed]
- My function echos only “array”
- Notify admin (by email) if post added with specific tag
- uploading a new theme to live server
- See output of a sql query while plugin installation in wordpress
- Shortcode Display From WordPress Dashboard Page Without Using post_id
- Warning: preg_replace(): Compilation failed: unknown option bit(s) set at offset -1
- Send foreach $_post method to contact form 7 [closed]
- Null value given when confirming email’s
- Predefine Magazine Style Layouts
- How to use url and amin-ajax.php
- WP – Ajax call back data printed in the console.log
- Dynamic Email Handler with ‘header (“Location: …’
- Creating an array with gettexed terms
- Execute wp_after_insert_post after the permalink is customized
- Adding a variable to some PHP code with gettext