Hello,
Thank you for contacting Rank Math today.
You have the following code on your theme to override the custom description that is set on the single listings page:
/**
* Allow changing the meta description sentence from within the theme.
*
* @param string $description The description sentence.
*/
add_filter( 'rank_math/frontend/description', function( $description ) {
global $post;
$desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
if ( $desc && is_singular('listing')) {
return RankMath\Helper::replace_vars( $desc, $post );
}
return $description;
});
This means that the description that is set on the Titles & Meta > Listings page will always be displayed on the frontend.
Looking forward to helping you. Thank you.
Earlier it was working.. i did change and everything was smooth, now it not working
Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
I have made a tweak to the code above in your theme function.php which seems to work. I may have also deleted the description for the listing, please add it again. The following is the code that seems to work
/**
* Allow changing the meta description sentence from within the theme.
*
* @param string $description The description sentence.
*/
add_filter( 'rank_math/frontend/description', function( $description ) {
global $post;
if ( $desc && is_singular('listing')) {
$desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
return RankMath\Helper::replace_vars( $desc, $post );
}
else{
$desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
}
return $description;
});
Looking forward to helping you. Thank 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.