Title: Regionality without multisite
Last modified: January 13, 2017

---

# Regionality without multisite

 *  [enuriru](https://wordpress.org/support/users/enuriru/)
 * (@enuriru)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/regionality-without-multisite/)
 * I’m about to create multi-regional site with very convenient structure.
 * 1. Cities are custom posts (using PODS)
    2. Every City has a title and “link”
   field (and more information in the future) 3. Pages are extended with a “city”
   custom field (related to Cities)
 * **The idea**
    If there is no page city_link.domain.com/page/ then display (not
   redirect) default_city_link.domain.com/page/. So I can create and modify only**
   one** page linked to default city and get the same content for 1000 other cities.
   And if I ever need to change the content for only one chosen city I’ll just create
   a modified copy of this page “in” chosen city.
 * So I think I need:
    1. Allow page slug duplicate. 2. Forbid page slug duplicate
   in single city 2. Add city link to permalinks (make them city_link.domain.com/
   page/) 3. Make WP know in which city we are using domain and display the correct
   page. 4. Make WP display default city page if there is no local version.
 * In the future:
 * 5. Make WP console know in which city we are
    6. Add a global dropdown filter
   that affects all content screens: posts, pages, custom posts — for display all
   content or only from current/chosen city. 7. Add an ability to add administrator
   for chosen cities.
 * **Why not multisite**
    Because I have to copy any new page to all sites then.
   And do the same if I modify some.
 * **Why not hierarchical page structure and .htaccess rewrites**
    The same.
 * I’ve been looking for at least partial solution but not succeeded.
    Any suggestions?
 * Thanks in advance.
    Den.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/regionality-without-multisite/#post-8653157)
 * It’s not possible to allow duplicate slugs for any given post type. You don’t
   need this functionality anyway. By using sub-domains, it’s going to involve rewrite
   rules, which are not the same as redirects, though similar. No way around it,
   and there is no harm in it. All permalinks involve rewrites, it’s how WP works.
   Unless you can (and want to) add sub-domain aliases for every city, your DNS 
   must allow wildcards.
 * You can achieve the bulk of this with a single template and some custom fields
   for each city for each section of the template. The template is setup to grab
   the custom field for the current city. If none exists, some default content is
   output instead.
 *  Thread Starter [enuriru](https://wordpress.org/support/users/enuriru/)
 * (@enuriru)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/regionality-without-multisite/#post-8654154)
 * Thank you for your reply!
 * > It’s not possible to allow duplicate slugs for any given post type.
 * The same time Polylang plugin allows this. And forbids duplication in single 
   language. I tried to dig up the code but haven’t enough WP experience to figure
   out how it works 🙁
 * OK, I can choose another way and make a hierarchical page structure like
 *     ```
       -default
       --page1
       --page2
       -city1
       --page2 (local version)
       -city2
       ```
   
 * Then,
    1) How could I “hide” the top level page slug from permalink and add it
   to domain? domain.com/city1/page/ -> city1.domain.com/page/ 2) How to hook 404
   error right and display default city page if there is no local?
 * I wrote the city detection already.
 *     ```
       add_action( 'plugins_loaded', 'detect_city');
   
       function detect_city() {
   
       	// TODO: rewrite to Singleton.
   
       	global $wp_city;
   
       	if (!defined('PODS_VERSION')) return;
   
       	$parts = explode('.', $_SERVER['HTTP_HOST']); //CITY.domain.com
       	if (count($parts) < 3) { // No CITY?
       		$city_slug = 'default';
       	} else {
       		$city_slug = $parts[0];
       	}
   
       	// Get the city from PODS
   
       	$wp_city = pods('city', $city_slug);
       	define('WP_CITY', $wp_city->display('id'));
       }
       ```
   
    -  This reply was modified 9 years, 4 months ago by [enuriru](https://wordpress.org/support/users/enuriru/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/regionality-without-multisite/#post-8655307)
 * Polylang is probably using a different post type for each language, so the no
   duplicates rule still applies. Like I said, there’s no need anyway.
 * You can alter permalink structures with the [Rewrite API](https://codex.wordpress.org/Rewrite_API).
   Not finding a city term does not result in a true 404 file not found error because
   permalinks never lead to true files in the first place. The lack of a proper 
   term results in the query failing to return anything. This condition is handled
   right on the template as the else condition to `if ( have_posts() )`
 * Sometimes the query will result in the 404.php template being loaded when the
   permalink cannot even be deciphered by the query. You can alter this file any
   way you want, but before doing that, consider why it’s being loaded instead of
   the template with the loop. If all is working correctly, the 404.php would never
   be loaded and the lack of a city term is handled by the else condition.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Regionality without multisite’ is closed to new replies.

## Tags

 * [city](https://wordpress.org/support/topic-tag/city/)
 * [custom posts](https://wordpress.org/support/topic-tag/custom-posts/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/regionality-without-multisite/#post-8655307)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
