/**
* 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;
});
u have already added code but not working
I did not get response, i just want to summerize my problem…
1. If I copy and paste the global meta in listing and modify something, then this meta must be shown.
2. If I dont edit any, then globle meta must shown…
but now global is shown even i modify anything in listing.
Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
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.
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,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hi team,
plz find temporary login detials.
https://suvidhasearch.com/?post_type=listing&p=10890&preview=true
i have a listing for your demo, dont do with my live listing.
and plz do let me know whatever you will do.bcz a lots of work going on my site so unable to check..
pls help asap.. thnx
Hello,
The code added previously seems to have been missing the if(!desc)
which is to check if the description is not provided and use the one set globally only then.
I added the following which seems to have fixed this issue, please check and let us know.
/**
* 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 && is_singular('listing')) {
return RankMath\Helper::replace_vars( $desc, $post );
}
}
return $description;
});
Please do not hesitate to let us know if you need our assistance with anything else.
old and new both code are in function.php
Hello,
Yes, the old code is there but commented so it doesn’t affect your website. Is the issue solved now or the new code doesn’t fix your issue?
Looking forward to help you.
Yeah, its working now..
Should I remove old code ?
Hello,
Yes, you can safely remove it, you shouldn’t have any issue with it.
Looking forward to help you.
hi,
got one issue again,
i have two directory type, 1. listing & 2. travel
and it is working with listing not with travel.
and i want it to work with both directory..
Hello,
The access you had provided seems to have expired.
You can replace this && is_singular('listing')
statement which checks isthe post type is a listing, in the code we had added and leave it to be as follows:
/**
* 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;
});
Looking forward to helping you. Thank you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
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.