6

I have to develop a multi-country, multi-lingual website. One country may have multiple languages. I have setup a WordPress Network and created subsites for each country like following.

abc.com/ > Global Website
abc.com/usa > USA Website
abc.com/fra > France Website

I am detecting Countries through Geo Location API and forcefully redirect them to their own country's website. Each country has their own set of languages e.g. France will have English and French with French as default language. I decided to use PolyLang for language translations. It works fine.

abc.com/fra/ > default french website
abc.com/fra/en > english translation of the french website.

The issue I am facing is I have duplicate english contents in every sub site. Is there anyway we can avoid duplicates and english version of subsites uses the english pages/posts from global site. Ideally, Admin should be able to select which one goes to sub site and which one does not.

There is an event section too, that can have global events as well as local/country level events.

I can think of following solutions and their drawbacks

  1. ThreeWP Broadcast plugin. This plugin broadcast page/posts to other sites on selection. Seems to be an excellent choice but duplicates the content what I am avoiding. Morover, I am not sure how it will work with PolyLang translations.

  2. Adding 'template_redirect' or 'wp' action, if subsite cant find a slug, and same slug is available in global site it should be populated and avoid 404. We also need to Intercept or override WP_Query calls to run same query on global site and return the results. About PolyLang, I am not sure how it will work. I guess, it can be sorted out. This approach is complicated and may end up no-where.

Anyone have any better solution? A plugin, or idea that can solve this interesting mystery?

I believe, its a common scenario for a multinational company. So, There has to be a viable solution to this.

2
  • Why not just flip the mappings? Have each language with its own site and redirect the user to the default language for their country with the option to chose a different language? Clarification on how different various country's content is might be useful.
    – Dan
    Dec 23, 2013 at 17:05
  • Okay this is about to tackle a front end user. I am more concerned to how to implement the backend structure with/without Multisite.
    – M-R
    Dec 23, 2013 at 17:41

1 Answer 1

0

R, the simple solution is to create a 2 post-meta.

The first is "Blog id" The second is "Post id"

and you use

$blog_id = get_post_custom_values('blog_id');
$post_id = get_post_custom_values('post_id');

if( !empty( $blog_id ) )
switch_to_blog( $blog_id );
    $query = new WP_Query( array( 'p' => $post_id ));
    if( $query->have_posts() ){
        while( $query->have_post() ){
            $query->the_post();   
        }
    }
restore_current_blog();

reference:

  1. http://codex.wordpress.org/Function_Reference/switch_to_blog
  2. http://codex.wordpress.org/Class_Reference/WP_Query
5
  • Can you explain it? I dont get it at all. Should every post of every subsite have these post metas? on what condition you are proposing to perform a switch?
    – M-R
    Dec 23, 2013 at 18:49
  • Yes all the post get the post_meta and you make the switch if the value of blog_id and post_id is not empty
    – Eduplessis
    Dec 23, 2013 at 19:04
  • So if you want the content of another post in another blog you just put the blog id and the post id
    – Eduplessis
    Dec 23, 2013 at 19:05
  • It is very basic code to fetch posts across the network but it does not explain how we can use it to implement the given scenario.
    – M-R
    Dec 23, 2013 at 19:44
  • Nice solution. You have to put the argument(s) of WP_Query inside an array, though.
    – tfrommen
    Dec 24, 2013 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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