• I want to add x-default tag to my whole websie i have a website with five languages i want x-default tag fall back to default language.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter kashifpkteam

    (@kashifpkteam)

    I have couple of more quesions
    1) how do we conditionaly check if the translation of a page or post exists or not and page has no translation.

    2) IF i am on Spanish page and i have to get url of my default language?

    Plugin Author Dennis Ploetner

    (@realloc)

    For the question that started the thread: MSLS will add “alternate” links for the “hreflang” in the header. As an example, the output at https://msls.co/:

    <link rel="alternate" hreflang="de" href="https://msls.co/de/" title="Deutsch" />
    <link rel="alternate" hreflang="en" href="https://msls.co/" title="English" />

    You can customize the outcome by using filter-hooks:

    For a single result with no translation

    add_filter( 'mlsl_output_get_alternate_links_default', function( string $default ) {
    // your code here

    return $default;
    }?);

    For an array of contents including the current content

    add_filter( 'mlsl_output_get_alternate_links_arr', function ( array $arr ) {
    // your code here

    return $arr;
    }?);
    Plugin Author Dennis Ploetner

    (@realloc)

    How can you conditionally check if a translation exists? How can you retrieve the URL of the translation of the current page in another language?

    You can probably hook into msls_filter_string (read on here https://msls.co/developer-docs/hook-reference/) or use an API function like get_msls_permalink() (read on here https://msls.co/developer-docs/api-functions/).

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.