правки test1

This commit is contained in:
2026-04-05 21:52:08 +03:00
parent ede86f4573
commit 4ba4a1e8f9
5 changed files with 98 additions and 1 deletions

View File

@@ -146,6 +146,16 @@ endif;
add_action( 'init', 'twentytwentyfour_block_styles' );
/**
* Enable base theme supports used by SEO integrations.
*
* @return void
*/
function twentytwentyfour_theme_setup() {
add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'twentytwentyfour_theme_setup' );
/**
* Enqueue block stylesheets.
*/
@@ -539,6 +549,93 @@ function twentytwentyfour_has_seo_plugin() {
return defined( 'WPSEO_VERSION' ) || defined( 'RANK_MATH_VERSION' );
}
/**
* Resolve SEO source page id for custom and WooCommerce contexts.
*
* @return int
*/
function twentytwentyfour_seo_context_page_id() {
if ( is_admin() ) {
return 0;
}
if ( is_page( array( 'test1', 'faq', 'contacts', 'delivery', 'service' ) ) ) {
return (int) get_queried_object_id();
}
if ( function_exists( 'is_cart' ) && is_cart() ) {
return (int) wc_get_page_id( 'cart' );
}
if ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() ) {
return (int) wc_get_page_id( 'checkout' );
}
if ( function_exists( 'is_shop' ) && is_shop() ) {
return (int) wc_get_page_id( 'shop' );
}
return 0;
}
/**
* Use Yoast SEO title from related page for custom templates.
*
* @param string $title Current Yoast title.
* @return string
*/
function twentytwentyfour_yoast_context_title( $title ) {
$page_id = twentytwentyfour_seo_context_page_id();
if ( $page_id <= 0 ) {
return $title;
}
$custom_title = (string) get_post_meta( $page_id, '_yoast_wpseo_title', true );
if ( '' === trim( $custom_title ) ) {
return $title;
}
$post = get_post( $page_id );
if ( function_exists( 'wpseo_replace_vars' ) && $post instanceof WP_Post ) {
$custom_title = wpseo_replace_vars( $custom_title, $post );
}
return wp_strip_all_tags( $custom_title );
}
add_filter( 'wpseo_title', 'twentytwentyfour_yoast_context_title', 20 );
/**
* Use Yoast SEO description from related page for custom templates.
*
* @param string $description Current Yoast description.
* @return string
*/
function twentytwentyfour_yoast_context_metadesc( $description ) {
$page_id = twentytwentyfour_seo_context_page_id();
if ( $page_id <= 0 ) {
return $description;
}
$custom_description = (string) get_post_meta( $page_id, '_yoast_wpseo_metadesc', true );
if ( '' === trim( $custom_description ) ) {
return $description;
}
$post = get_post( $page_id );
if ( function_exists( 'wpseo_replace_vars' ) && $post instanceof WP_Post ) {
$custom_description = wpseo_replace_vars( $custom_description, $post );
}
return wp_strip_all_tags( $custom_description );
}
add_filter( 'wpseo_metadesc', 'twentytwentyfour_yoast_context_metadesc', 20 );
/**
* Get long-form SEO text for cart and checkout pages.
*

View File

@@ -25,7 +25,7 @@ $test1_header_mode = isset( $test1_header_mode ) ? $test1_header_mode :
</a>
<nav class="nav" aria-label="Основная навигация">
<a href="<?php echo esc_url( home_url( '/test1/#catalog' ) ); ?>">Каталог</a>
<a href="<?php echo esc_url( home_url( '/shop/' ) ); ?>">Каталог</a>
<a href="<?php echo esc_url( home_url( '/delivery/' ) ); ?>">Доставка</a>
<a href="<?php echo esc_url( home_url( '/service/' ) ); ?>">Для дома и офиса</a>
<a href="<?php echo esc_url( home_url( '/faq/' ) ); ?>">FAQ</a>