The Aelia Currency Switcher includes a country selector widget, which can be displayed anywhere by using a shortcode or the built-in widget component. Please find below the instructions to use each feature.


1. Displaying the widget using the shortcode

By using the currency selector shortocde, It's possible to display the widget on any page. You can use the shortcode as in the example below:

[aelia_cs_country_selector_widget title="Widget title (optional)" widget_type="dropdown|dropdown_flags"]

The shortcode accepts the following parameters:

  • title
    The widget title (optional).
  • widget_type
    The widget type. The Currency Switcher supports the following widget types:
    • dropdown (default). A simple dropdown selector. 
    • dropdown_flags. A dropdown selector, with flags displayed next to each country. Note: this widget type is available since version 4.12.0 of the Aelia Currency Switcher.


Additional custom types can be added by implementing a filter in your theme for wc_aelia_cs_customer_country_selector_widget_types hook. If this parameter is not specified, dropdown widget type will be rendered by default.


How to use the shortcode via PHP

If you would like to call the shortcode from your template's code, you can use WordPress' do_shortcode() function, like in the following example: 

// Display the widget as a dropdown list
echo do_shortcode('[aelia_cs_country_selector_widget  title="My widget title" widget_type="dropdown"]');

// Display the widget as a dropdown list, with flags
echo do_shortcode('[aelia_cs_country_selector_widget title="My widget title" widget_type="dropdown_flags"]');

For more information about using shortcodes via PHP, please refer to WordPress Codex. Function Reference/do shortcode/.


2. How to display the country selector using a WordPress widget

The country selector widget can be dragged and dropped like any standard WordPress widget (see below).


Simply drag and drop the country selector widget to the appropriate target area. The configuration form will allow you to choose the widget type and additional options.


How to create a new widget area

If you don't have a widget area in the location where you would like to display the country selector, the easiest and most reliable solution is to use the shortcode (see above). If you would rather create a new widget area (called "sidebar", in WordPress), you can do so by following the instructions below:

  1. Open your theme's functions.php file. It's located in /wp-content/themes/<your theme folder>/functions.php.
  2. Register a new widget area with the following code:  

    // Register a new sidebar
    function my_widget_area_init() {
      register_sidebar( array(
        'name' => 'My widget area',
        'id' => 'my_widget_area',
        'before_widget' => '<div class="widget widget_wc_aelia_currencyswitcher_widget">',
        'after_widget' => '</div>',
        'before_title' => '<h2 class="rounded">',
        'after_title' => '</h2>',
      ) );
    }
    
    add_action( 'widgets_init', 'my_widget_area_init' );
  3. Go to the Wordpress Admin Panel > Appearance > Widgets. The widget area you just added should now be visible on the right. Drag and drop the country selector in the new widget area,
  4. Open the theme file that displays the page section where you would like to display the new widget area (for example, let's suppose /wp-content/themes/<your theme folder>/header.php for the header) and add the following code in the exact place where you would like the area to appear: 

    // Render the new sidebar registered earlier
    dynamic_sidebar('my_widget_area');

    Save the file and refresh the page. Now the country selector will be displayed in the area you just added.


You can purchase the Aelia Currency Switcher from our online shop.