Client just asked me to return different Facebook page links based on the language/region categories of Wordpress posts. For instance, if a user lands on a blog post in Portuguese, the FB icon in the header will dynamically change to "facebook.com/brandnamebrasil" instead of the default "facebook.com/brandname"
Here's my best attempt so far adding PHP meta in the theme header file. Any advice or pointers would be greatly appreciated:
<?php
$theurl = $_SERVER['REQUEST_URI'];
$thecat = explode("/", $theurl);
$post_cat = $thecat[2];
if($post_cat == "category")
{$post_cat = $thecat[3];}
else
{$post_cat = $thecat[2];}
else if($post_cat == "latin-america-pt")
{$the_cat_url = "latin-america-pt/?lang=pt-br"; $mast_url="/wp-content/brasil_header.jpg"; $facebook_link = "https://www.facebook.com/brandnamebrasil";}
else
{$the_cat_url = $post_cat; $facebook_link="https://www.facebook.com/brandname/";}
?>
<div style="position:relative; display: inline; width:1026px; height:128px; background: #fff; margin-top: 45px; padding: 10px 15px;"><a href="<?php echo site_url(); ?>/<?php echo $the_cat_url;?>"><img src="<?php echo site_url(); ?><?php echo $mast_url; ?>" border="0"/></a>
<a href="<?php echo $facebook_url;?>" style="display:block; float:right; padding:10px 17px 0px 10px;" target="_blank"><img src="/wp-content/uploads/2016/07/FB.jpg" class="social-icons"></a>
<a href="http://instagram.com/brandname" style="display:block; float:right; padding:10px 17px 0px 10px;" target="_blank"><img src="/wp-content/uploads/2016/07/instagram.jpg" class="social-icons"></a>
<a href="http://twitter.com/brandname" target="_blank" style="display:block; float:right; padding:10px 17px 0px 10px;" target="_blank"><img src="/wp-content/uploads/2016/07/twitter.jpg" class="social-icons"></a>
<a href="http://pinterest.com/brandname" style="display:block; float:right; padding:10px 17px 0px 10px;" target="_blank"><img src="/wp-content/uploads/2016/07/pinterest.jpg" class="social-icons"></a>
</div>