Overview
ShahiTranslate Pro provides multiple shortcodes and WordPress widgets to place language switchers anywhere on your site. Use shortcodes in posts, pages, or custom templates, and widgets in sidebars or footer areas.
Shortcodes
Language Switcher Shortcode
Basic Usage:
`
[shahitranslate]
`
or shorter version:
`
[stp]
`
What It Does:
Displays the configured language switcher widget inline within your content.
Example:
Add to any post or page:
`
Welcome to our site!
[shahitranslate]
Choose your language above to view content in your preferred language.
`
Result:
Language switcher appears between the text, using your configured widget style.
Shortcode Parameters
Override Widget Style:
`
[shahitranslate widgetlook=”dropdownwith_flags”]
`
Available Styles:
dropdownwithflags– Nice dropdown with flag iconsdropdown– Simple text dropdownflags– Flags only (inline)flags_dropdown– Flags with dropdown listpopup– Popup modalglobe– Globe iconfloat– Floating buttoninline(default) – Appears where shortcode is placedfloating– Fixed position (not recommended in shortcode)lang_names– “Spanish” (language name)lang_codes– “ES” (code uppercase)flags– Flag image onlyflags_name– Flag + “Spanish”flags_code– Flag + “ES”- Add “Shortcode” widget
- Paste:
[shahitranslate] - Style the container
- Add “Shortcode” module
- Enter:
[stp widget_look="flags"] - Adjust spacing
- Add “Shortcode” element
- Input:
[shahitranslate] - Configure column
- Add “Code” module
- Content:
[stp] - Style module
- Add “Shortcode” block
- Type:
[shahitranslate] - Preview
- Add “Paragraph” block
- Type:
[stp widgetlook="flagsdropdown"] - Converts automatically
- ShahiTranslate Pro – Language Switcher
- Go to Appearance β Widgets
- Find “ShahiTranslate Pro – Language Switcher”
- Drag to sidebar (e.g., “Primary Sidebar”)
- Configure settings
- Click “Save”
- Primary Sidebar
- Footer Widget Area 1
- Footer Widget Area 2
- Header Widget Area (if theme supports)
- Good for blogs
- Visible on all pages
- Doesn’t interrupt content
- Universal placement
- Doesn’t clutter header
- Easy to find
- Most prominent
- Quick access
- May need custom CSS
widget_look– Style of switcherposition– Display position- Switcher Text Color: #333
- Switcher Background: #fff
- Switcher Border: #ccc
- Dropdown Text: #000
- Dropdown Background: #eee
- Plugin not activated
- Shortcode typed incorrectly
- Conflict with page builder
- Verify plugin is active:
- Check spelling:
- Use HTML block in Gutenberg instead of Paragraph
- Try do_shortcode() in PHP:
- Widget area not displayed in theme
- No languages enabled
- CSS hiding widget
- Check widget area:
- Enable languages:
- Check CSS:
- Test different widget area
- CSS not loading
- Theme conflict
- Missing styles
- Clear cache:
- Check CSS loaded:
- Add custom CSS:
- Increase specificity:
- Multiple switchers in content
- Switcher on every page section
- Repetitive placement
- One visible switcher per page
- Consistent placement across site
- Switcher visible on mobile
- Touch-friendly (min 44px tap targets)
- Doesn’t break layout
- Language Switcher Options
- Design Customization
- Translation Methods
- Advanced Hooks
Example with Style:
`
[stp widget_look=”flags”]
`
Displays flags inline without dropdown.
Position Parameter
Inline vs Floating:
`
[shahitranslate position=”inline”]
`
Options:
Recommended: Always use inline for shortcodes
Single Language Link Shortcode
Display Individual Language:
`
[stp-lang lang=”es”]
`
Displays a single link to Spanish version.
Parameters:
| Parameter | Description | Example |
|———–|————-|———|
| lang | Language code (required) | lang="es" |
| label | Custom text label | label="EspaΓ±ol" |
| widgetlook | Display style | widgetlook="flags_name" |
Display Styles:
Examples:
Text Only:
`
[stp-lang lang=”es” widgetlook=”langnames”]
`
Output: Spanish
Flag Only:
`
[stp-lang lang=”es” widget_look=”flags”]
`
Output: πͺπΈ
Flag + Name:
`
[stp-lang lang=”es” widgetlook=”flagsname”]
`
Output: πͺπΈ Spanish
Flag + Code:
`
[stp-lang lang=”fr” widgetlook=”flagscode”]
`
Output: π«π· FR
Custom Label:
`
[stp-lang lang=”es” label=”En EspaΓ±ol”]
`
Output: En EspaΓ±ol
Multiple Language Links
Create Custom Language Menu:
`
`
Output:
`
π¬π§ English
πͺπΈ Spanish
π«π· French
π©πͺ German
`
Style with CSS:
`css
.custom-lang-menu {
display: flex;
gap: 15px;
justify-content: center;
padding: 20px;
background: #f5f5f5;
}
.custom-lang-menu a {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 15px;
border: 1px solid #ddd;
border-radius: 5px;
text-decoration: none;
color: #333;
}
.custom-lang-menu a:hover {
background: #fff;
border-color: #0073aa;
}
.custom-lang-menu .stp-current-lang {
background: #0073aa;
color: #fff;
border-color: #0073aa;
}
`
Using Shortcodes in Templates
PHP Template
In Theme File (header.php, footer.php, etc.):
`php
`
With Parameters:
`php
shortcode( ‘[shahitranslate widgetlook=”flags”]’ ); ?>
`
Example in Header:
`php

`
Page Builder Shortcodes
Elementor:
Beaver Builder:
WPBakery:
Divi:
Gutenberg Block
Classic Block:
Paragraph Block:
HTML Block:
`html
`
WordPress Widgets
Language Switcher Widget
Location: Appearance β Widgets
Available Widget:
Adding Widget:
Widget Settings:
| Setting | Description | Options |
|———|————-|———|
| Title | Widget title | “Choose Language” |
| Widget Look | Display style | Dropdown, Flags, etc. |
| Show Title | Display title | Checkbox |
Example Configuration:
`
Title: Select Language
Widget Look: Nice Dropdown with Flags
β Show Title
[Save]
`
Widget Areas
Common Widget Areas:
Choosing Best Location:
Sidebar:
Footer:
Header:
Multiple Widget Instances
Use Different Styles in Different Areas:
Header Widget (flags only):
`
Title: (empty)
Widget Look: Flags
β Show Title
`
Sidebar Widget (dropdown):
`
Title: Languages
Widget Look: Nice Dropdown with Flags
β Show Title
`
Footer Widget (text links):
`
Title: Choose Your Language
Widget Look: Simple Dropdown
β Show Title
`
Custom Placement Methods
Direct Function Call
In Template Files:
`php
exists( ‘stplanguage_switcher’ ) ) {
stplanguageswitcher( array(
‘widgetlook’ => ‘dropdownwith_flags’,
‘position’ => ‘inline’
) );
}
?>
`
Parameters:
Example in Footer:
`php
`
Hook Integration
Add Switcher to Menu:
Automatic (via settings):
`
Settings β Switcher β Show in Menu
Select menu location: Primary Menu
Save
`
Manual (via code):
`php
function myaddlangtomenu( $items, $args ) {
if ( $args->theme_location == ‘primary’ ) {
$switcher = doshortcode( ‘[stp widgetlook=”flags”]’ );
$items .= ‘
‘;
}
return $items;
}
addfilter( ‘wpnavmenuitems’, ‘myaddlangtomenu’, 10, 2 );
`
Add Switcher After Header:
`php
function myaddlangafterheader() {
echo ‘
‘;
}
addaction( ‘wpbodyopen’, ‘myaddlangafter_header’ );
`
Elementor Custom Widget
Create Custom Elementor Widget:
`php
// functions.php
class MyLanguageSwitcherWidget extends \Elementor\WidgetBase {
public function get_name() {
return ‘stplanguageswitcher’;
}
public function get_title() {
return ‘Language Switcher’;
}
public function get_icon() {
return ‘eicon-globe’;
}
public function get_categories() {
return [ ‘general’ ];
}
protected function render() {
echo do_shortcode( ‘[shahitranslate]’ );
}
}
function registerstpelementorwidget( $widgetsmanager ) {
$widgetsmanager->register( new MyLanguageSwitcherWidget() );
}
addaction( ‘elementor/widgets/register’, ‘registerstpelementorwidget’ );
`
Styling Shortcodes
CSS Customization
Target Shortcode Output:
`css
/ Container /
.shahitranslate-wrapper {
margin: 20px 0;
text-align: center;
}
/ Dropdown style /
.shahitranslate-wrapper select {
padding: 10px 15px;
border: 2px solid #ddd;
border-radius: 5px;
font-size: 16px;
background: #fff;
cursor: pointer;
}
/ Flags inline /
.shahitranslate-wrapper a {
margin: 0 5px;
transition: transform 0.2s;
}
.shahitranslate-wrapper a:hover {
transform: scale(1.1);
}
/ Current language highlight /
.stp-current-lang {
border: 2px solid #0073aa;
border-radius: 3px;
padding: 2px;
}
`
Responsive Design
Mobile-Friendly Shortcodes:
`css
/ Desktop /
.shahitranslate-wrapper {
display: flex;
justify-content: center;
gap: 15px;
}
/ Mobile /
@media (max-width: 768px) {
.shahitranslate-wrapper {
flex-direction: column;
align-items: center;
}
.shahitranslate-wrapper a {
display: block;
width: 100%;
padding: 10px;
text-align: center;
border: 1px solid #ddd;
margin: 5px 0;
}
}
`
Custom Widget Styling
Via Settings:
`
Settings β Design & Colors
Custom CSS:
.shahitranslate-wrapper {
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
border-radius: 8px;
padding: 10px;
}
`
Via Theme CSS:
`css
/ In your theme’s style.css /
.widget_shahitranslate {
background: #f9f9f9;
padding: 20px;
border-left: 4px solid #0073aa;
}
.widget_shahitranslate .widget-title {
color: #0073aa;
font-size: 18px;
margin-bottom: 15px;
}
`
Use Cases
1. Blog Post Language Notice
Scenario: Notify readers they can switch language
Implementation:
`html
This article is available in multiple languages:
[stp-lang lang=”en” widgetlook=”flagsname”]
[stp-lang lang=”es” widgetlook=”flagsname”]
[stp-lang lang=”fr” widgetlook=”flagsname”]
`
2. Landing Page Hero Section
Scenario: Prominent language choice on homepage
Implementation:
`html
Welcome to Our Platform
Choose your language to get started:
`
3. Footer Global Language Bar
Scenario: Site-wide language options
Implementation:
`php
`
4. E-commerce Product Page
Scenario: Product descriptions in multiple languages
Implementation:
`html
[stp-lang lang=”en” widgetlook=”langcodes”]
[stp-lang lang=”de” widgetlook=”langcodes”]
[stp-lang lang=”fr” widgetlook=”langcodes”]
`
5. Navigation Menu Integration
Scenario: Language switcher in main menu
Automatic Method:
`
Settings β Switcher β Show in Menu
Menu Location: Primary Menu
Save Changes
`
Manual Method (better control):
`php
function addlanguageto_nav( $items, $args ) {
if ( $args->theme_location == ‘primary’ ) {
$lang_switcher = ‘
‘;
$items .= $lang_switcher;
}
return $items;
}
addfilter( ‘wpnavmenuitems’, ‘addlanguageto_nav’, 10, 2 );
`
6. Sidebar Contextual Widget
Scenario: Language widget in blog sidebar
Widget Configuration:
`
Appearance β Widgets
Sidebar: Primary Sidebar
Add Widget: ShahiTranslate Pro – Language Switcher
Title: Read in Your Language
Widget Look: Nice Dropdown with Flags
β Show Title
Save
`
Advanced Shortcode Usage
Conditional Display
Show Shortcode Only on Certain Pages:
`php
function conditionallanguageswitcher( $content ) {
// Only show on single posts
if ( is_single() ) {
$switcher = ‘
$switcher .= doshortcode( ‘[shahitranslate widgetlook=”flags”]’ );
$switcher .= ‘
‘;
return $content . $switcher;
}
return $content;
}
addfilter( ‘thecontent’, ‘conditionallanguageswitcher’ );
`
Dynamic Parameters
Change Style Based on Device:
`php
function responsivelanguageswitcher() {
if ( wpismobile() ) {
return doshortcode( ‘[stp widgetlook=”globe”]’ );
} else {
return doshortcode( ‘[stp widgetlook=”dropdownwithflags”]’ );
}
}
// Use in template
echo responsivelanguageswitcher();
`
Custom Shortcode Wrapper
Create Your Own Shortcode:
`php
function mycustomlang_shortcode( $atts ) {
$atts = shortcode_atts( array(
‘style’ => ‘modern’,
), $atts );
$output = ‘
$output .= ‘π Language:‘;
$output .= doshortcode( ‘[stp widgetlook=”dropdownwithflags”]’ );
$output .= ‘
‘;
return $output;
}
addshortcode( ‘mylang’, ‘mycustomlang_shortcode’ );
// Usage:
// [my_lang style=”modern”]
`
Troubleshooting
Shortcode Not Rendering
Symptom: [shahitranslate] shows as text
Causes:
Solutions:
`
Plugins β Installed Plugins β ShahiTranslate Pro (Active)
[shahitranslate] or [stp] (not [shahi-translate])
`
Widget Not Appearing
Symptom: Widget added but not visible on site
Causes:
Solutions:
`
Visit frontend β View Page Source
Search for widget area ID
Settings β Languages β Select at least 2 languages
Inspect element
Look for display:none or visibility:hidden
`
Styling Issues
Symptom: Shortcode looks broken or unstyled
Causes:
Solutions:
`
Browser cache, plugin cache, server cache
View Page Source β Look for:
/wp-content/plugins/shahitranslate-pro/assets/css/frontend.css
Settings β Design β Custom CSS
.shahitranslate-wrapper.shahitranslate-wrapper { / styles / }
`
Multiple Switchers Conflict
Symptom: Two switchers on page, both change together
Expected: They should work independently
Explanation: This is normal behavior. All language switchers on the same page switch the site language globally. Clicking any switcher affects all content.
Why: Language preference is site-wide, not per-widget.
Best Practices
1. Choose Appropriate Style for Context
Header/Menu: Globe or compact flags
Sidebar: Dropdown with flags
Footer: Simple dropdown or text links
Content: Popup or flags inline
2. Don’t Overuse
Avoid:
Recommended:
3. Make It Accessible
Screen Readers:
`php
Choose your preferred language
`
Keyboard Navigation:
Ensure dropdown is keyboard accessible (built-in).
4. Test on Mobile
Always verify:
5. Consistent Branding
Match language switcher design to your theme:
`
Settings β Design & Colors
Use your brand colors
`
Next Steps
Share this article
Still need help?
Our support team is ready to assist you with personalized guidance for your workspace.