Last active
November 22, 2024 06:29
-
-
Save sybrew/014931e5589293cc0f3ea9b57f6d6f8a to your computer and use it in GitHub Desktop.
Adjust WooCommerce title for The SEO Framework with "Hot " at the start.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do not include the PHP opening tag if PHP is already opened. | |
add_filter( | |
'the_seo_framework_title_from_generation', | |
function ( $title, $args ) { | |
$is_product = false; | |
$is_product_category = false; | |
if ( isset( $args ) ) { | |
switch ( \The_SEO_Framework\get_query_type_from_args( $args ) ) { | |
case 'term': | |
$is_product_category = 'product_cat' === $args['tax']; | |
break; | |
case 'single': | |
$is_product = tsf()->query()->is_product( $args['id'] ); | |
} | |
} else { | |
if ( tsf()->query()->is_product() ) { | |
$is_product = true; | |
} elseif ( \function_exists( 'is_product_category' ) && is_product_category() ) { | |
$is_product_category = true; | |
} | |
} | |
if ( $is_product || $is_product_category ) { | |
$title = "Hot $title"; | |
} | |
return $title; | |
}, | |
10, | |
2, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment