A short description of a product is inserted in the meta description
-
I found this code from you and it works, but it applies meta product description and for product categories and product attributes.
If I paste the code, it takes the global meta description and inserts it into product, category and product attributes.
When the code is inserted, the meta description is applied to these page categories:
https://oilx.org/product-category/motornoe-maslo/ (category)
https://oilx.org/brand/mobil/ (attribute)
https://oilx.org/product/motornoe-maslo-cat-ngeo-40-208-l-105-3336/ (product)And I need it to apply only to the product:
https://oilx.org/product/motornoe-maslo-cat-ngeo-40-208-l-105-3336/ (product)How can I make the code be used only for products?
Regards Denis
Code
/**
* Use the Description from Global Setting, if the description is missing in the Post metabox
*/
add_action( ‘rank_math/frontend/description’, function( $description ) {
global $post;
$desc = RankMath\Post::get_meta( ‘description’, $post->ID );if ( ! $desc ) {
$desc = RankMath\Helper::get_settings( “titles.pt_{$post->post_type}_description” );
if ( $desc ) {
return RankMath\Helper::replace_vars( $desc, $post );
}
}return $description;
});
- The topic ‘A short description of a product is inserted in the meta description’ is closed to new replies.