We've two WordPress websites on two domain names. Among each language.

Within our header.php file, the next code is located:

The below code is proven around the French website

<a href="http://www.french-url.com/?page_id=<?php the_ID(); ?>">English</a>

The below code is proven around the British website

<a href="http://www.english-url.com/?page_id=<?php the_ID(); ?>">Fran├žais</a>

If we are around the British website, and then click the hyperlink to go to in france they website, we obtain rerouted to some 404 Page Not Found Error: BECAUSE the page is redirecting to some URL ending having a code like so '?page_id=155'.

Now, if we are around the French website, and then click the hyperlink to go to the British website, the redirection works perfectly. The URL proven is '?page_id=' With No NUMBER in the finish.

We wish to bare this code intact for each other page, aside from the home page. Say you are going to an about-us page, or contact-us page, or perhaps a blog publish, the next code should remain there:

?page_id=<?php the_ID()' ?>

Can now someone please let me know when the following scenario will make sense, and when so, please show some code regarding how to have great results:

Make an if/else statement stating that if you're around the home page, then only redirect towards the selected URL (with no added code page_ID in the finish from the URL).

It's difficult to understand without seeing those sites under consideration, however it seems like all pages besides the home page have ?page_id=NUMBER within the URL. if that is the situation, it can be done such as this:

<a href="http://www.english-url.com/<?php if ($_GET['page_id']){ echo '?page_id='; the_ID(); } ?>">Fran├žais</a>

This can only add the ?page_id=NUMBER query into pages which have one occur their very own URL.