Создать для городов новый тип записей city
Добавить города, где post_name города == поддомену
Шорткод
function city_shortcode(){ $domain = explode('.', $_SERVER['HTTP_HOST']); if (!empty($domain[0]) && !empty($domain[1]) && !empty($domain[2])) { $page = get_page_by_path($domain[0], OBJECT, 'city'); return $page->post_title; } }add_shortcode('city', 'city_shortcode');
Дополнительно если нужно
function add_shortcode_to_filds( $text ){ return do_shortcode($text); } apply_filters( 'the_content', 'add_shortcode_to_filds' );//для работы шорткодов в заголовке страницыadd_filter( 'the_title', 'add_shortcode_to_filds' );//для работы шорткодов в заголовках и описании плагина wpseoadd_filter( 'wpseo_title', 'add_shortcode_to_filds' );add_filter('wpseo_metadesc','add_shortcode_to_filds');//для работы шорткодов в полях от плагина acfadd_filter('acf/format_value/type=textarea','add_shortcode_to_filds');add_filter('acf/format_value/type=text','add_shortcode_to_filds');
//изменение ссылок на субдоменfunction replace_sity_permalink($permalink, $post){ if ($post->post_type == 'sity') { $permalink = str_replace(array( '/sity/' . $post->post_name, '://' ), array( '', '://' . $post->post_name . '.' ), $permalink); } return $permalink;}add_filter('post_link', 'replace_sity_permalink', 20, 3);add_filter('post_type_link', 'replace_sity_permalink', 20, 3);
function wp_rel_nofollow2( $text ) { // This is a pre-save filter, so text is already escaped. $text = stripslashes( $text ); $text = preg_replace_callback( '|<a (.+?)>|i', function( $matches ) { return wp_rel_callback( $matches, 'sponsored nofollow' ); }, $text ); return wp_slash( $text );}function category_nofollow( $the_content ) { global $post; if( in_category( array(438) ) ) { $the_content = stripslashes( wp_rel_nofollow2( $the_content ) ); } return $the_content;} add_filter('the_content', 'category_nofollow');
А что, в вордпрессе регистрации нету?
Плагины для того и придуманы, чтобы не пихать все подряд в ядро.
Вместо html с оздайте index.php
С помощью яндекса можно определять город и далее автоматически перенаправлять на нужный адрес или спрашивать у пользователя, его ли это город и предложить выбор.
Подстановку города в нужное место делать в зависимости от урл.
Сами города занести в массив
'msk' => Москва'',
'ufa' => Уфа'',
к хуку нужно функцию ципануть
add_action('wp','my_func');function my_func() {$id = get_queried_object_id();echo $id;}
Ревизии записей + медиафайлы хранятся в таблице wp_posts, по этому такая последовательность
Сделайте бренды через таксономию.
А вводить товары из определенной категории и определенного бренда можно по фильтру category_name=slug категории&brand=slug бренда