WordPress.org

Ready to get started?Download WordPress

Forums

polylang 404 page in 2 languages (5 posts)

  1. elisabetha
    Member
    Posted 1 year ago #

    Polylang works fine for me, but I would like to show the 404 page in the 2 languages I use for my site. Can this be done with polylang, or must I add something in 404.php to catch the language the visitor has chosen?

  2. Chouby
    Member
    Posted 1 year ago #

    Out of the box, Polylang should load the 404 page in the right language (if your theme 404 page is localized). How Polylang chooses the language depends on the options you have chosen.

  3. elisabetha
    Member
    Posted 1 year ago #

    Thanks. However, in my theme Sonar there's 1 php in English which always comes up, also when I'm visiting a Dutch page. When I try to create a page called 404 to link it to 404_dutch.php this won't work.

  4. elisabetha
    Member
    Posted 1 year ago #

    I solved it like this in 404.php:

    <p><?php $taal=pll_current_language($value);?>

    <article id="post-0" class="post error404 not-found">
    <h1 class="entry-title">
    <?php if ($taal =="nl") {
    echo "Niet gevonden" ;}
    ?>
    <?php if ($taal =="en") {
    echo "Not Found" ;}
    ?></h1>

    etc.

  5. Chouby
    Member
    Posted 1 year ago #

    That's a way. The most common way used by plugins and themes is:

    <article id="post-0" class="post error404 not-found">
    <h1 class="entry-title">
    <?php _e("Not Found", 'my_theme');
    ?></h1>

    And then translate a the theme with the .po / .mo files.
    See http://wordpress.org/support/topic/plugin-polylang-how-to-internationalize-a-theme

Topic Closed

This topic has been closed to new replies.

About this Topic