Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm helping with a custom multi language site. We have one page in English, then an equivalent page in French. I've got a "SWITCH LANGUAGE" link in the main container (next to the breadcrumbs) that takes you to the English home page if on any French page, and vice versa.

Aside from using a plugin, how can I make this link more dynamic by having it point to the equivalent page, whether French or Engligh? E.g. when a user is on the "Events" page, the l ink points to the "Evènements" page, but when on the "Fundraising" page, it points to "Levée de fonds" page.

Here's the code I'm using now to switch languages, using custom fields to give all Engligh pages a Name of "MenuName" and a Value of "English". This then serves either the breadcrumbs.php or my new breadcrumbs-en.php, which has the appropriate link to it. I don't think this is the best way to do this however, since it is dependent on the breadcrumbs.

<?php

if (get_post_meta($post->ID,'MenuName', true))
  {
  get_template_part('includes/breadcrumbs-en','page');
  }
else
  {
  get_template_part('includes/breadcrumbs','page');
  }
?>

So I'm looking more for the theory of linking the two pages, by way (I think) of assigning custom field values for each page(?)

share|improve this question

2 Answers 2

There is a plugin named Multilingual Press doing exactly what you described.

As a lightweight solution, you could create a network table to store the relations and a metabox for all posts where you can search and assign posts from other pages to update the network table.

Do not use post meta data. You would have to synchronize two different tables, that will break sooner or later. Never store the same information in two places.

share|improve this answer
    
Thanks I'm going to give this a try (the plugin). :) –  Drewdavid Oct 27 '12 at 18:53
    
This is working out well, now I just need to figure out how to show the link outside of a widgetized area (I know many plugins also offer a php snippet to insert the HTML wherever you want). Any ideas? :) –  Drewdavid Oct 30 '12 at 18:47
    
In Multilingual Press look at the function mlp_show_linked_elements(). You can use that function wherever you need it. –  toscho Oct 30 '12 at 19:41
    
Thanks, I ended up making a new widgetized area and placing the widget there. –  Drewdavid Jan 24 '13 at 2:55

You can use the Relationship field of Advanced Custom Fields Add the field to each page and select the "equivalent page" (either English or French) from a simple dropdown field.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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