Skip to content

Docs

Everything needed to install the plugin, show the switcher and extend it from your own theme.

Installation

Install from the WordPress plugin directory, or with WP-⁠CLI.

wp plugin install multilify --activate

The Switcher

Use the shortcode in any post or page, or the template tag in a theme file. Both take show_flag and show_name, on by default: pass show_name="false" for flags only. With both off the name stays, so a link is never empty. On a post the links lead to that post in each language, elsewhere to each language's home.

[multilify_switcher]

<?php multilify_switcher(); ?>

Filters

Translate any post type, and hook into the output where you need to.

add_filter( 'multilify_post_types', function ( $types ) {
    $types[] = 'product';

    return $types;
} );

Every Filter

Seven filters, and that is the whole surface.

multilify_post_types
Which post types get translation panels. Add product for WooCommerce.
multilify_translated_title
The translated title as the theme prints it. It receives the stored translation (empty when there is none), the original title, the post ID and the language code. The browser tab title does not pass through it.
multilify_translated_content
The translated content, before it is output. It receives the stored translation (empty when there is none), the original content, the post ID and the language code.
multilify_flag_choices
The flags offered in the language picker on the settings screen, as a map of language code to emoji.
multilify_locale
The WordPress locale a language switches to. It defaults to an installed locale that matches the code, such as de_DE for de, and to the site locale when none is installed.
multilify_enable_browser_detection
Whether a first-time visitor on the site root is sent to their browser's language. Return false to turn it off.
multilify_is_crawler
Whether a request counts as a crawler, which browser language detection never redirects. It receives the built-in result and the user agent.

Language Codes

A language code is two to five lowercase letters, such as tr or de. It becomes the URL prefix and the key every translation is stored under, so it cannot be changed after you add it. The page's lang attribute and the hreflang tags print it too. Words WordPress already uses in addresses, such as feed, page and wp, and any code an existing post or page uses as its slug, are refused.

What the Addresses Look Like

The default language keeps WordPress' own addresses. Every other language adds its code in front: /tr/, /tr/post-slug/, /tr/parent/child/. Pagination, feeds, search and comment pages work under the prefix too. On a site with a static front page, /tr/ shows that page in Turkish.

Slugs and Fallbacks

A slug field left empty uses the post's own slug under the language's prefix. Slugs are unique within a language: a duplicate becomes -2, -3, and a slug another post already uses as its own counts as taken.

Where Translations Are Stored

Each language adds three post meta rows to a post: _multilang_title_{code}, _multilang_content_{code} and _multilang_slug_{code}. The language list and the default language are the options multilify_languages and multilify_default_language, and the slug lookup uses an index named multilify_slug_lookup on the post meta table.

Moving Content in with a Script

Write the three meta rows for each post and language, from WP-⁠CLI or an importer. Every write clears the plugin's caches, so a slug set from a script works at once. A script skips the checks the editor panel makes, so it has to sanitize the slug, keep it unique within the language and clean the content itself.

Sitemaps

With two or more languages, each language other than the default gets its own sitemap in WordPress' built-in sitemap index. It lists the language's home page and every published entry that has a title or content in that language.

Deactivating and Deleting

Deactivating the plugin removes its rewrite rules and keeps all data. Deleting it from the WordPress admin removes every _multilang_ meta row, its options and its index, on every site of a network.

What It Does

Unlimited Languages
Add as many as you need. There is no tier that caps the count.
Custom Slugs Per Language
Give each language its own slug for a post. Nested pages keep their translated parents in the path.
Cached Slug Lookup
Translated slugs are found through an index on the post meta table, and each result is object-cached and dropped when the slug changes.
Stays on Your Server
No third-party translation API, no outbound calls, nothing to sign up for.
hreflang and lang
Alternate tags with x-default on posts and language homes, a lang attribute that follows the page, a Content-Language header to match, and a sitemap for each extra language.
Gutenberg and Classic
In the block editor and the classic editor alike, each language gets a panel on the post itself with its own title, slug and a visual editor for the content.

What It Will Not Translate

Stated plainly, because finding out after installing is worse.

  • Page builders that render from their own stored data, such as Elementor. Multilify translates what passes through the_content, which covers the block editor and the classic editor.

  • Menus and widgets. Multilify translates the title, slug and content of posts, pages and any post type you add. Excerpts, categories and tags, and custom fields are not translated.

  • WooCommerce prices, attributes and variations. Product titles and long descriptions translate once you add product through the multilify_post_types filter. Short descriptions are excerpts, which are not translated.

Requirements

Checked against the plugin directory when this page was built.

needs WordPress
WordPress 5.8 or later
needs PHP
PHP 7.4 or later
tested up to
WordPress 7.1.5
license
GPL v2 or later