Site owner has a Wordpress blog in English and a translation service for Spanish; however, to keep costs down, the posts with high traffic are being translated to Spanish manually and will be cut from the translation service. So each of those high-traffic posts have an English and Spanish version. So, we want to add an hreflang to the function.php, But, only for those pages we are manually translating. Hope this makes sense.
Found the below, the only thing is it is going to get rather large as we add more and more of the high-traffic post. So, kind of two-fold question:
1. Will the function below work? If not, can you help me adjust it to work?
2. What happens as more and more blog ids are added to this function. Will performance be affected?
Just thought I'd give the forum a whirl, in the event anyone has dealt with something like this before.
Thanks in advance for any advice,
Jamie
Found the below, the only thing is it is going to get rather large as we add more and more of the high-traffic post. So, kind of two-fold question:
1. Will the function below work? If not, can you help me adjust it to work?
2. What happens as more and more blog ids are added to this function. Will performance be affected?
PHP Code:
function add_hreflang_tags() { if (is_front_page() || is_home()) { echo '<link rel="alternate" hreflang="es" href="https://es.example.com/blog" />'; } if (is_single('1234')) { echo '<link rel="alternate" hreflang="en-es" href="https://es.example.com/blog/" />'; } } add_action('wp_head', 'add_hreflang_tags');
Thanks in advance for any advice,
Jamie
Comment