2

I am new to WordPress, and I have a problem building my website. I use the Sydney theme and Polylang plugin for my multilanguage website.

I have build a website in 4 different languages and now I would like to have a different footer text for every language in the sub footer part.

For e.g. where it says in English language 'Copyright I Privacy policy' ', with the hyperlink on provacypolicy/en, that I have created. For the German start page the subfooter language should auto change in 'Copyright I Datenschutz', with the hyperlink from Datenschutz on the German page with privacypolicy/de that I have created. And also the same for the other languages.

I tried to edit that in the footer.php but I had no luck.

My existing code for <div class="site-info container"> in footer.php is:

© <?php echo date("Y"); ?> | Company name | All rights reserved | <a href=
"http://localhost/companyname/wordpress/privacy-policy/">Privacy policy</a> 

When I go to my german language it should change to:

© <?php echo date("Y"); ?> | Company name | Alle Rechte vorbehalten | <a href=
"http://localhost/companyname/wordpress/datenschutz/">Datenschutz</a>

And the same for other two languages.


I RESOLVED THE ISSUE.

For anyone that will have the same problem, use the if - endif code in your footer.php.

enter image description here

9
  • Welcome to WPSE. Unfortunately, your issue seems to be with the Polylang plugin, not with WordPress in general. You're more likely to get an answer at the plugin author's forum: wordpress.org/support/plugin/polylang – cjbj Aug 27 '18 at 10:23
  • I don't think that the problem is with poly lang, because the free version of polylang probably doesn't have this function for subfooter. I think you can change the footer with polylang, add it as widget for different languages, but not for subfooter. I tried various 'if-else' codes in Edit footer.php, but it didn't work. – BR Management Aug 27 '18 at 11:01
  • You mean the subfooter text is hardcoded in the theme? – cjbj Aug 27 '18 at 11:03
  • I changed the original text in the theme "Powered by..." to my in footer.php and added the link for the text to new site, but only in my primary language. Now when you choose another language, the subfooter text doesn't change. – BR Management Aug 27 '18 at 11:10
  • 1
    If you have found the answer, please include it as an answer and accept it. If you do it as an edit to the question, this question will remain flagged 'unsolved' in the database. – cjbj Aug 27 '18 at 15:38
0

For the text in the theme to be able to be translated, the text should be passed as an argument through the localization functions __(), _e().

echo __( 'Sample text to display', 'theme-textdomain' );
_e( 'Sample text to display', 'theme-textdomain' );

More functions and details you can find here


In your case it could look like this:

© <?php 
echo date("Y"); 
$page_id = 'ID_of_privacy_policy_page';

if ( function_exists('pll_get_post') )
    $page_id = pll_get_post( $page_id );
$p_link = get_the_permalink($page_id);
$p_title = get_post_field('post_title', $page_id);

printf(' | %s | %s | <a href="%s">%s</a>', 
    'Company name',
    __('All rights reserved', 'some_textdomain'),
    esc_url($p_link),
    esc_html($p_title)
);

$page_id can be hardcoded or set with $page_id = get_page_by_path('privacy-policy')->ID;.

$page_id = pll_get_post( $page_id );

The obove line will get ID of "Privacy policy" page in current language.

The next step is to prepare a files with the translation de_DE.po, de_DE.mo and for 2 other languages. Edit existing files in your theme or create new ones if needed. A list of sample tools is available on the codex website, among others Loco Translate, Poedit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.