13年专注400电话服务 | 续费不涨价,当天开通

全国400电话城市分站

邦尊科技覆盖全国300+城市,提供本地化400电话办理服务

📞 💬
/** * Get a single city by slug. * * @param string $slug City pinyin slug. * @return array|false City data or false if not found. */ function bz400_get_city( $slug ) { $cities = bz400_get_cities(); if ( isset( $cities[ $slug ] ) ) { return $cities[ $slug ]; } // Also check by pinyin field foreach ( $cities as $city ) { if ( $city['pinyin'] === $slug ) { return $city; } } return false; } /** * Check if the current request is a city page by slug. * * @return string|false City slug or false. */ function bz400_is_city_page() { $slug = get_post_field( 'post_name', get_the_ID() ); $cities = bz400_get_cities(); if ( isset( $cities[ $slug ] ) ) { return $slug; } return false; } /** * Output Schema structured data for city pages. */ function bz400_city_schema() { if ( ! bz400_is_city_page() ) { return; } $slug = bz400_is_city_page(); $city = bz400_get_city( $slug ); if ( ! $city ) { return; } $phone = bz400_phone(); $address = get_option( 'bz400_company_address', '重庆市九龙坡区石桥铺一城精英国际15层' ); $email = get_option( 'bz400_contact_email', '1120513787@qq.com' ); $site_url = home_url( '/' ); $schema = array( '@context' => 'https://schema.org', '@type' => 'LocalBusiness', 'name' => '重庆邦尊科技有限公司 - ' . $city['name'] . '400电话办理', 'image' => get_template_directory_uri() . '/screenshot.png', 'telephone' => $phone, 'email' => $email, 'url' => home_url( '/' . $slug . '/' ), 'priceRange'=> '399-9999元/年', 'address' => array( '@type' => 'PostalAddress', 'streetAddress' => '石桥铺一城精英国际15层', 'addressLocality' => '重庆', 'addressRegion' => '重庆', 'postalCode' => '400000', 'addressCountry' => 'CN', ), 'areaServed' => array( '@type' => 'City', 'name' => $city['name'], ), 'openingHours' => 'Mo-Fr 09:00-18:00', 'description' => $city['seo_desc'], ); echo '' . "\n"; } add_action( 'wp_head', 'bz400_city_schema', 2 ); /** * Output city-specific SEO meta tags (description, keywords, geo). */ function bz400_city_seo_meta() { $slug = bz400_is_city_page(); if ( ! $slug ) { return; } $city = bz400_get_city( $slug ); if ( ! $city ) { return; } echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; } add_action( 'wp_head', 'bz400_city_seo_meta', 0 ); /** * Override page for city sub-station pages. * Works with add_theme_support('title-tag'). */ function bz400_city_document_title( $title ) { $slug = bz400_is_city_page(); if ( ! $slug ) { return $title; } $city = bz400_get_city( $slug ); if ( $city && isset( $city['seo_title'] ) ) { $title['title'] = $city['seo_title']; // Remove site name suffix to keep the title clean if ( isset( $title['site'] ) ) { unset( $title['site'] ); } } return $title; } add_filter( 'document_title_parts', 'bz400_city_document_title', 20 ); /** * Get city list for navigation links. * * @return array Array of [slug, name, url] pairs. */ function bz400_get_city_list() { $cities = bz400_get_cities(); $list = array(); foreach ( $cities as $slug => $city ) { $list[] = array( 'slug' => $slug, 'name' => $city['name'], 'url' => home_url( '/' . $slug . '/' ), ); } return $list; }