Auto generate post discription

#115141
Viewing 3 replies - 16 through 18 (of 18 total)
  • Hello,

    Sorry for not following up quickly and any inconvenience that might have been caused due to that.

    Can you please try adding following filter code to your theme’s functions.php file:

    
    add_filter( 'rank_math/frontend/description', function( $description ) {
    	if ( ! is_singular() ) {
    		return $description;
    	}
    
    	global $post;
    	$meta_desc = get_post_meta( $post->ID, 'rank_math_description', true );
    	return $meta_desc ? $meta_desc : get_the_excerpt( $post );
    } );
    

    I wanted to add this to your site but the login details you added in the Sensitive Data Section are not working anymore. If adding this filter code doesn’t fix the issue then please regenerate the username and password and add them to the Sensitive Data Section.

    Looking forward to helping you.

    Thank you. It works like a charm.

    one thing, on the main page, the description is shown, but on editing mode(wp-admin/post.php), on rankmath’s google preview box is shown like before. I mean it just shows the embed content.

    Hello,

    Glad to hear that worked for you.

    Do not be worried by the preview. This will still take the excerpt data as before but the share code runs and overrides this when the post is opened in the front end showing the correct meta.

    Hope this helps

Viewing 3 replies - 16 through 18 (of 18 total)

You must be logged in to reply to this ticket.