Transfer from English page to Arabic page

I have a button at the top of the website in header.php. That button should transfer me to the Arabic version of the page if I am on an English page.

For example, on contact.html the button should transfer me to contact-ar.html and on info.html the button should transfer me to info-ar.html.

Read More
<li><a href="#">arabic</a></li>

I want to know if there is any way to edit part of the header.php from outside?

Related posts

Leave a Reply

2 comments

  1. Try the following. This is given that the original page url has a .html in it (contact.html and info.html)

    <li><a href="<?php
    if (false !== strpos(strtolower($_SERVER['REQUEST_URI']), '.html')) {
        $uri = str_replace('.html', '-ar.html', strtolower($_SERVER['REQUEST_URI']));
    } else {
        $uri = '';
    }
    echo home_url($uri);
    ?>">arabic</a></li>
    
  2. The button might not be the best route to solve this problem. If your aim is to have a separate page for each language then look into using the WordPress ML plugin. This will give you the tools (and buttons) to properly have your site be in two languages.