Archived topic
Display content in GP Hooks based on language
7 replies · Started by Peter Islin Nielsen on May 12, 2016
Hi Tom,
Any tricks on how to display content placed in GP Hooks based on the language of the current page?
I have a site in English with a slider placed just before the footer by using the GP Hooks add-on. Now I need to make a version in Chinese with the aid of Polylang – and the content in the slider is going to be translated as well. But how do I show the English slider on the English pages, and the Chinese slider on the Chinese pages only. I could do it with CSS display:none, but that just doesn't feel right :-)
I think you can do something like this for example:
<?php if ( is_single() && 'Russian' == pll_current_language('name') ) : ?>
We're on a single post and Russian is the language
<?php endif; ?>
More info on their functions: https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/
Thanks, this works like a charm! And sorry for not going through the Polylang docs first (which I of course should've done). I guess your continuous great support is making me lazy :-)
No problem at all! I'm sure someone will stumble upon this topic and it will help them too :)
Hi Tom,
You were right. I stumbled upon your answer a couple of days before, and it helped me too. Thanks! :-)
The only issue is that I need the message to be displayed in all single posts except in a specific post. Is it possible?
You could use some PHP, but it might be worth looking at GPP 1.7 which is currently in public testing: https://generatepress.com/gp-premium-1-7/
The new hook system allows you to set Display Rules, which would help with what you're after :)
Can't wait to get the next update, it looks wonderful! Thanks, Tom. :-)
Thank you! :)