Site logo

Archived topic

Polylang and Footer content

11 replies · Started by Dan on January 13, 2018

Viewing posts 1–12 of 12

Hi,
I have a site with 2 languages.
Would you know how can I change the footer credit (Edited via the customizer) for each language?
I am using the Polylang plugin.

Thanks
Dan

Yes, polylang supports it too.
I was wondering why doesn’t The customizer change per language and if it’s a wp, GP or polylang thing.
And if there’s an option without the hook.

Thanks
Dan

I believe WPML gives you an option to change the Customizer option per language, as we've included a compatibility file that looks for specific theme options in WPML. Not sure if Polylang has something like that?

Hi Tom, didn't see that in Polylang,
As a previous user of WPML, my impression is that this plugin slows the site down so I have been trying out Polylang.
Maybe it's worth asking the Polylang author for a compatibility file like in WPML.

Till that is solved I used the "Before Footer Content" to replace the credit line based in the language selected.

<?php
add_filter( 'generate_copyright','tu_custom_copyright' );
function tu_custom_copyright()  { ?>
<?php if (get_locale() == 'en_US'): ?>
---English content---
<?php endif; ?>
<?php if (get_locale() == 'he_IL'): ?>
---Hebrew Content---
<?php endif; }?>

Thanks,
Dan

Definitely nothing wrong with that method :)

Polylang currently works with Generatepress Elements,

so my solution is

  • Create a Hook and choose a language
  • Hook->footer
  • Disable Site Footer
  • Execute PHP
  • Display Rules -> Location -> Entire Site

with this code

<footer class="site-info" itemtype="https://schema.org/WPFooter" itemscope=""><div class="inside-site-info grid-container grid-parent"><div class="copyright-bar"> <span class="copyright">&copy; <?php echo date('Y'); ?> <?php echo get_bloginfo( 'name' ); ?></span> • Powered by <a href="https://generatepress.com" itemprop="url">Generate8Press</a></div></div></footer>

and so on for the rest of the languages. Now you have a custom footer for each language.

Maybe is not very elegant, but It does the job. Any better solution?

The method that Dan mentioned above makes it so you don't need to remove the default footer - it just filters the content.

However, there isn't anything wrong with your method, either :)

Thanks for this info. But I don't know where do I need to put this code? Could you help me? Thank you again.

<?php
add_filter( 'generate_copyright','tu_custom_copyright' );
function tu_custom_copyright()  { ?>
<?php if (get_locale() == 'en_US'): ?>
---English content---
<?php endif; ?>
<?php if (get_locale() == 'he_IL'): ?>
---Hebrew Content---
<?php endif; }?>

Hi Diego,

Can you try adding this through Code snippets?:

add_filter( 'generate_copyright','tu_custom_copyright' );
function tu_custom_copyright()  {
if (get_locale() == 'en_US'):
endif;
if (get_locale() == 'he_IL'):
endif; }

Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets

Thanks. It works for me.

You’re welcome Diego!

This archived topic is closed to new replies.