Developer Docs

Add Ons & Tools Automatic Translation Developer Docs FAQ Getting Started Licence & Support MultilingualPress WordPress Multisite 1x1

  • How to assign a language via WP-CLI

    Starting from MultilingualPress version 4, assigning a language to a subsite through WP-CLI is possible. Open your shell and go to the WordPress directory where the MultlingualPress plugin is installed and activated. From there, if you want to assign to the sub-site with id 41, the Spanish language, for example, you can use the following…

    Read more

  • How to translate Taxonomy Slugs

    In this brief tutorial we show how to translate taxonomy slugs using the multilingualpress.filter_term_public_url filter hook available in MultilingualPress. Set the environment for our example code snippet Here below we provide an example snippet with two sub sites that have respectively an ID with value 1, and a second one with value 2. Of course…

    Read more

  • How to run code when the “Copy source content” option is checked

    In this tutorial we are going to show how to run your code snippet when the option Copy source content is selected in the translation metabox. The translation metabox A translation metabox lets you to define some settings related to the post translations that are available in another language sub site. When you edit a…

    Read more

  • How to create a custom language switcher in MultilingualPress

    In this tutorial we will create a custom language switcher using the MultilingualPress API. We will start creating a simple language menu and then convert it to a select dropdown. Finally we will explain how to add the language switcher to a WordPress widget. Get translations for the current page In order to create a…

    Read more

  • How to copy post meta to the remote sites

    This code snippet shows how to copy post meta to the remote site(s). In the example it gets the value of yoast_wpseo_title post meta from the request and then updates the value in the connected sites. add_action('multilingualpress.metabox_after_relate_posts', function($context, $request) { // get post meta value from source site $yoastWpseoTitleValue = (string)$request->bodyValue( 'yoast_wpseo_title', INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );…

    Read more

  • How to programmatically connect content

    If you want to connect content programmatically across sites you need to know the IDs of the posts you want to connect beforehand. So let say that we have 3 sites with site ids 1, 2 and 3 and we want to connect a post with the following post ids on each site: post id…

    Read more

  • How to get connected post IDs by current post ID

    To get an array of connected posts you can use the translationIds function. That method is the equivalent of mlp_get_linked_elements in MultilingualPress 2: The first parameter is the source post id, the second is the column “type” in the wp_mlp_relationships table in the database and the third parameter is the source site id. About the type…

    Read more

  • How to get content translations programmatically

    In order to get current content translations of the current post in MultilingualPress, you can use the Translations class passing the arguments via TranslationSearchArgs. Here is an example: add_filter('the_content', function($content) { $args = \Inpsyde\MultilingualPress\Framework\Api\TranslationSearchArgs::forContext( new \Inpsyde\MultilingualPress\Framework\WordpressContext() )->forSiteId(get_current_blog_id())->includeBase(); $translations = \Inpsyde\MultilingualPress\resolve( \Inpsyde\MultilingualPress\Framework\Api\Translations::class )->searchTranslations($args); foreach ($translations as $translation) { $postId = $translation->remoteContentId(); $title = $translation->remoteTitle(); $url =…

    Read more

Inpsyde
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.