[Resolved] Display content in GP Hooks based on language

Home Forums Support [Resolved] Display content in GP Hooks based on language

Home Forums Support Display content in GP Hooks based on language

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #193740
    Peter Islin Nielsen

    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 πŸ™‚

    • This topic was modified 7 years, 11 months ago by Peter Islin Nielsen.
    #193804
    Tom
    Lead Developer
    Lead Developer

    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/

    #193851
    Peter Islin Nielsen

    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 πŸ™‚

    #193868
    Tom
    Lead Developer
    Lead Developer

    No problem at all! I’m sure someone will stumble upon this topic and it will help them too πŸ™‚

    #644705
    Leo

    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?

    #644875
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #645646
    Leo

    Can’t wait to get the next update, it looks wonderful! Thanks, Tom. πŸ™‚

    #645841
    Tom
    Lead Developer
    Lead Developer

    Thank you! πŸ™‚

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.