Could someone kindly share the variable to achieve this — I’m not much of a coder.
I’m surprised to see so many options, but “long description” not one of them.
Rank Math even has “%wc_shortdesc%” wondering this differs from “%excerpt%” if they’re said to display the same thing.
FYI, this said code I found does not work (or no longer works):
add_action( 'rank_math/frontend/description', function( $description ) {
if ( ! is_singular() ) {
return $description;
}
global $post;
$desc = RankMath\Post::get_meta( 'description', $post->ID );
if ( $desc ) {
return $desc;
}
if ( empty( $post ) || empty( $post->post_content ) ) {
return $description;
}
$keywords = RankMath\Post::get_meta( 'focus_keyword', $post->ID );
$post_content = RankMath\Paper\Paper::should_apply_shortcode() ? do_shortcode( $post->post_content ) : $post->post_content;
$post_content = \preg_replace( '/<!--[\s\S]*?-->/iu', '', $post_content );
$post_content = wpautop( $post_content );
$post_content = wp_kses( $post_content, [ 'p' => [] ] );
// 4. Paragraph with the focus keyword.
if ( ! empty( $keywords ) ) {
$regex = '/<p>(.*' . str_replace( [ ',', ' ', '/' ], [ '|', '.', '\/' ], $keywords ) . '.*)<\/p>/iu';
\preg_match_all( $regex, $post_content, $matches );
if ( isset( $matches[1], $matches[1][0] ) ) {
return $matches[1][0];
}
}
// 5. The First paragraph of the content.
\preg_match_all( '/<p>(.*)<\/p>/iu', $post_content, $matches );
return isset( $matches[1], $matches[1][0] ) ? wp_html_excerpt( $matches[1][0], 160 ) : '';
});