Display Meta description for human visitors

[ad_1]

My theme don’t have any feature to display post meta description below post title or <h1>.

So I decided to display generated by Yoast meta description. I want to get the description that I have written when publishing article using Yoast plugin.

ChatGPT gave me to automatically get description under a paragraph generated by Yoast plugin.

<p class=”sub-title”> <?php $post_id = get_the_ID(); $post_description = get_post_meta( $post_id, ‘_yoast_wpseo_metadesc’, true ); if ( ! empty( $post_description ) ) { echo $post_description; } ?></p>

it will work? Still _yoast_wpseo_metadesc works to get description? Because I found wpseo_metadesc. Which one will work and comfortable with latest version of the plugin and WP 6.1

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer