0

I'm building a website where there are some posts that will be relevant only for users from a specific country, so I would like that the user select his country so that he can view all the content minus (-) the content that is specific to other countries.

For example: The user can select between Argentina, Chile, Mexico. He chooses Chile. He will be able to see all the content except the content that is specific from Argentina and Mexico.

--more description--

I believe 80% of the content will be not country specific.

For example, if there is a category named "TV" which has:

  • general TV posts -> content relevant for everybody (eg: Game of Thrones related posts)
  • TV Argentina -> content relevant only for argentinians (eg.: local soap opera)
  • TV Chile
  • TV Mexico If the user chooses "Argentina" he must be able to see posts all posts in TV category except Chile and Mexico.

I'm not sure how to accomplish this. It would be great if the user can choose his country from a dropdown and this filter gets applied to the whole website.

Other info: Language is the same for all countries and there is user-generated content

How would you approach this? Thank you for reading

0

Creating a multisite would be the most efficient approach in this scenario. You could have a structure like this:

---> example.com
     ---> example.com/chile
     ---> example.com/argentina
     ---> example.com/mexico

The benefit of a multisite is that it's easy to separate all your content from the beginning. And you can use a plugin like Multisite Post Duplicator to duplicate posts in between the subsites if you need them to appear in different places.

  • Thanks for your answer wiredfordesign. Most of the content will be "shared". ut Very interesting plugin, bI didn't find too much info about it. Do you know if it will duplicate the posts as if I have 10 multisites it will be copied 10 times (with all the cons)? or it just makes the post be available on the chosen subsites? I need to manage thousands of posts. Thanks again. – brantesaurio Aug 30 '17 at 18:18
  • @brantesaurio If you have 10 multisites and you want a post to appear in all 10, you can choose the sites that you want it to appear in. So yes, it will be duplicated 10 times such that you can see the post in each subsite. But you can link all the posts so that editing one will change all of the copies. – wiredfordesign Aug 30 '17 at 18:22
  • Thank you @wiredfordesign, I see this would work but for my specific project I think it would not be effective, I'm afraid that I didn't made clear that I'm expecting the user to categorize the post when he creates it, telling "this post is relevant only for Argentina or some other country". – brantesaurio Aug 31 '17 at 16:09
0

you have 2 options based on the volume of the content:

If the specific content for a country its a lot and users need to be separated by country, create a Multisite, a site for each country:

|-yoursite.com
|
|--chile.yoursite.com
|
|--argentina.yoursite.com
|
|--mexico.yoursite.com

If the specific content for each country is not much, use a value (category, tag, custom field, etc), so when they select argentina, only the content with the value "argentina" will be shown.

Custom Field

Example:

<?php 

$country_val = get_post_meta($post->ID, "country", true); 
$selected_country = "arg"; //get this from session or user?? cookie?

if(!empty($country_val)){
   //there is a country value
   //we check if the country of the content is the same as the selected
   if($country_val == $selected_country){
      echo "This is content specific and for the selected country!!";
   }
}else{
   echo "This is Content for all, since it doesnt have a country value";
}


?>
  • Thank you for your answer David. Second option feels more like my case, but what about the content that is not country-specific (majority of the content)? it will not be shown if he chooses "argentina" – brantesaurio Aug 30 '17 at 18:04
  • Why it will be not shown? In the conditional you can check first if its content-specific if not just show it, if its start checking if its for the country selected. That would be 2 conditionals, you can create a function that returns true or false and use it in the front-end. – David Lee Aug 30 '17 at 18:32
  • I added an example code (didnt test it) showing the general idea, if there is no country specified then is not restricted so, Show it! – David Lee Aug 30 '17 at 19:55
  • Thank you David! I think this approach is going the right way, I realized that for now this is beyond my capabilities since I don't even know how to accomplish part 1, getting the user to fill the $selected_country. I'll study and update the answer when I can test the code you wrote. – brantesaurio Aug 31 '17 at 15:56

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.