Product Category Meta Description Template not working

#82049
  • Resolved Peter
    Rank Math free

    I’m trying to set a meta description template for our product categories, but it doesn’t seem to be working.
    It keeps defaulting to using the product template meta description instead.

    Now I did add in some code that I found in another support repsonse to the functions file in order to get our Product meta description templates to function but it appears that it’s overriding everything else.

    Any ideas?

    Code attached below:

    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;
    });
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    You will need to check if the page is a product category page before adding the description:

    
    add_action( 'rank_math/frontend/description', function( $description ) {
    	global $post;
    	$desc = RankMath\Post::get_meta( 'description', $post->ID );
    
    	if ( ! $desc && is_product_category()) {
    		$desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
    		if ( $desc ) {
    			return RankMath\Helper::replace_vars( $desc, $post );
    		}
    	}
    
    	return $description;
    });
    

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    Peter
    Rank Math free

    Hi Michael,

    Thanks for the reply. This still doesn’t seem to be working.

    Product Archive
    Product Category

    These should be the priority description for the product category page, but it seems to still be pulling the template for an individual product and using the first product in the category to populate the information.

    It would be great to get this sorted if possible.

    Thanks,
    Peter

    Peter
    Rank Math free

    product-archive
    product-category-archives

    Original image links used wrong link so reattaching here.

    Hello,

    Are you talking about the preview only? Or, the actual meta description?

    Do you have an example of a product category archive where you entered a meta description and it is pulling something else?

    Peter
    Rank Math free

    Hi Uzair,

    The actual meta description doesn’t use the global meta description for product categories.

    https://shop.rigquip.com/product-category/mud-pump-parts/

    As an example, this URL above should at the moment show the meta description of “This doesn’t work” as per is set by the screenshot above, but it doesn’t. It’s pulling in:

    meta-data

    This is the template for a single product and it’s using the data from the first product on that category page.

    Hopefully that makes sense.

    Thanks,
    Peter

    Hello,

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)

The ticket ‘Product Category Meta Description Template not working’ is closed to new replies.