It's silly to have dropdown when you have only two languages. Makes sense if there are more. I want to have just a simple button that will switch to the other language and I can't find any guide on google.
How to switch between 2 languages with a button and not a dropdown with WPML?
1.1k views Asked by Ivailo Ivanov At
3
There are 3 answers
0
Andrea
On
I add the css here to include the | "Pipe" between two languages in the switcher
.wpml-ls-statics-shortcode_actions li:nth-of-type(1) .wpml-ls-link:after{
content:"\00a0 \00a0|" !important;
display:inline-block !important;
}
/*fix padding switcher WPML */
.wpml-ls-legacy-list-horizontal a{
padding-left:2px !important;
padding-right:2px !important;
}
0
sotirov
On
Use this to show the buttons:
<?php
do_action('wpml_add_language_selector');
?>
You can change the way it looks from the Admin panel -> WPML -> Languages -> Custom language switchers -> Customize.
If you don't see the Customize button, click Enable checkbox in the Custom language switchers section and it will appear.
Related Questions in WORDPRESS
- How to add the dynamic new rows from my registration form in my database?
- Wordpress Site - pages have low text-HTML ratio
- wordpress delete unwanted location
- How to create a facet for WP gridbuilder that displays both parent and child custom fields?
- How to change woocomerce or full wordpress currency with value from USD to AUD
- error 500 on IIS FastCGI but no clue despite multiple error loggings activated
- Caching private wordpress rest endpoints
- How do i get my close button to work on a popup?
- SQL query to get student enrolled in this month in a course - Moodle
- What wordpress plugin prevent sharing of contact information amongst users?
- Password protected or private URL one-time viewable video access
- Download button not working in wordpress website. How can solve it?
- WP toolkit problem after deleting wordpress site manually
- TypeError: Failed to execute 'arrayBuffer' on 'Blob': Illegal invocation - Insert blob into database
- New Order Email Details Missing // Woocommerce / Woocommerce Bookings
Related Questions in PLUGINS
- Chrome/Firefox plug-in for automatically opening the dev tools and executing code in the console
- Creating a modal window in product edit page in Shopware6 and saving data to custom table(repository) from a form within the modal window
- Swiper.js moves slides outside of viewport/page
- Responsive Lightbox & Gallery issue
- Unity - How to add C++ file directly to be used as a Plug-in
- Can not switch camera while recording with camera plugin, setDescription working but preview doesn't change
- can anyone help me for NSIS Script I have a case where I need to check cases can be 3.3 3.42 23.5 23.56w 3.467 999.999 999.99a but not 1.b or 8..a
- How can I know if a vscode intelliSense suggestion is visible?
- Loader / Spinner infinite | Filter Everything Pro
- HTML Not Rendering and Displaying as Plain Text on Frontend with Ninja Forms in WordPress
- I want to run my own interface that I coded with Python in RoboDK
- How to redirect uploads from customers to go into specific folder?
- TestNG update related issue
- Co Author Plus: Need to add co authors names with link
- JS-issue "undefined query" when trying to create chrome-plugin
Related Questions in TRANSLATION
- DirectX 9 With No SDK Installed - How To Translate a D3DMATRIX?
- How to modify features of tfidfvectorizer from English to Spanish
- integrate huggingface inference endpoint with flowise
- System.Recources.Resourcemanager only finds the 'default' .resx file (translation file) based on the CultureInfo object
- How do I implement bilingual sentence alignment for English and Japanese texts in Python and export them to XLSX?
- TypeError: Translator.translate() missing 1 required positional argument: 'text'
- Parameterisation of yup translation - next.js
- Displaying Marathi(Non English Characters) using PIL library onto the OpenCV Interface not working as needed
- Updating comments with references in .po translation
- Langchain/Huggingface Pipeline Error about model_kwargs which I did not include
- Getting error when upload training data for Azure Custom Translator using API with C#
- How do I display a language like Hindi, Marathi that don't have English characters in an open cv feed?
- Use a default/fallback value if the translation is not available in Lingui, React
- Why doesn't video-conferencing with subtitles exist?
- Error configuring flask-babel method jinja2 not found
Related Questions in WPML
- Wordpress WPML automatically duplicates other languages when a user posts a Listing
- How can I display a php page in my overlay using WPML tags?
- WPLM - first url dosnt show language
- How to create a global product attribute and its translations programmatically with WooCommerce+WPML
- WooCommerce display Product Attributes on shop page compatible with multi-language
- Getting Post, Page, CPT and Archive page IDs using URL
- How to get the Custom flag for a Language using Language Code in WPML
- Retrieving Other language Links using WPML Language Code and Post ID retrieved from Post URL
- Timber upgrade 1.19 site.language deprecated?
- Confirmation (return) links missing on hreflang pages WPML Wordpress
- WPML source default language for some WooCommerce products
- WPML integration with Mega Menu
- Synching ACFPro repeater fields across languages with wpml-config.xml
- How to translate a custom permalink for a CPT custom taxonomy?
- Compatibility problem between WPML and Divi on Dynamic content
Related Questions in CODE-TRANSLATION
- How to translate MatExpr statements(comparing a Mat with int threshold) used in OpenCV in C++ to EmguCV in C#?
- Can I Convert PHP Code to Perl in a Semi-Automated Way?
- Problems and Inaccuracies Converting + Interpreting Unity Shadergraph to C#
- Is the Dafny to Python code certified? If so, why does not Python have native pre-post options? If not, why translate it?
- Cannot translate from Dafny to Python using recommended "dafny build --target:py A.dfy"
- How to switch between 2 languages with a button and not a dropdown with WPML?
- Node.js: How to import/require a file, run its commands and access its updated variables like in Python?
- Why does passing a large dictionary from python to julia flatten contained multidimensional lists?
- trying to convert C to Lisp
- Java to Solidity translator: is there a possibility to write smart contracts in Java?
- Calculating euclidean distance in a matrix
- Translate back to english before sending the search parameter using weglot
- is there any way to convert this python code into php
- Converting Visual Basic 6 source code into Java
- Converting from PyTorch to Tensorflow for Self-Attention Pooling Layer
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)

You need to create a custom language switcher.
The first step is to add the PHP code responsible for rendering the language switcher on your page. For that, you create a function that adds a div container with the language switcher inside it. We can use the wpml_add_language_selector action to render the language switcher.
In this example, we want the new language switcher to be displayed in the footer, so we use our new function with the WordPress’s own wp_footer hook.
The complete PHP code will look like this.
You can copy and add it to your (child) theme’s functions.php file.
With the previous code in place, we already have a new language switcher added to the footer of our website. Now, it’s time to customize it so that it is floating in the bottom right corner of the website. You can do this using the position: fixed CSS attribute.
Use the following steps to add the CSS code:
Alternatively, you can add this CSS code by going to Appearance → Customize and clicking Additional CSS.
The following example adds some extra customization like rounded borders and box-shadow. Of course, you can customize it as you want.
Finally, you need to adjust some settings so the language switcher displays only the flags.
Use the following steps:
You can find the complete documentation at WPML webiste.