WP multisite mobile header custom button added as anchor link in header.php how to set one for each site

61 Views Asked by At

Currently this anchor link is added to my header.php file which adds a custom GET STARTED button to a mobile header.

<a class="button_cta_mobile" href="<?php echo home_url() . '/subscribe/'; ?>">GET STARTED</a>

It works great, but now that I've "upgraded" to a multilingual WP multisite, I need a unique anchor link for each site. Domain is the same all over, only with country subdirectories like /de /uk and so on. Basically different slugs and text languages.

So what I'm wondering is, if even possible, can I add more anchor links pointing at different directories from header.php, and somehow exclude or include them at each of my sites?

1

There are 1 best solutions below

7
Sviat Kuzhelev On

To solve this you can use the if else conditions, that will filter buttons display by url adress or part of it if you want( by contains method).

Exemple: ** UPDATE**

`<php? 
  $var = echo page_url();
  $strVal = strval($val);
  if ($strVal contains '/en/') {
    '<a class="button_cta_mobile" href="<?php echo home_url() . '/en/subscribe/'; ?>">GET STARTED</a>'
  } else {
    '<a class="button_cta_mobile" href="<?php echo home_url() . '/subscribe/'; ?>">GET STARTED</a>'
 } ?>`