Site logo

Archived topic

Why meta description of Yoast not displayed?

3 replies · Started by Mohamed on August 29, 2020

Viewing posts 1–4 of 4

Hi,

the meta description of Yoast not displayed with the theme
so, I tried to run this code

function add_custom_meta_des(){
if(is_tax()):
$yoast_desc = get_term_meta( get_queried_object_id() , '_yoast_wpseo_metadesc', true );
else:
$yoast_desc = get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', true );
endif;

$metadesc_val = wpseo_replace_vars($yoast_desc, $post );
$metadesc_val = apply_filters( 'wpseo_metadesc', $metadesc_val );

	if( ! empty( $yoast_desc ) && !is_page('compare') ){	echo '<meta name="description" content="' . $yoast_desc . '" />';}
    echo get_term_meta( get_queried_object_id() , '_yoast_wpseo_metadesc', true ) .'cx';  
  }
add_action( 'wp_head', 'add_custom_meta_des', 4 ); 

But it didn't works !!

Hi there,

Where did you get the code from?

Have you checked with YoastSEO's support?

Does the code work in a twenty series WP default theme?

Hello Leo,

I research and tried to add this code because the meta description of Yoast not displaying be default in GeneratePress although it works with other theme like Publisher, so I don't need to ask Yoas support
Could you help?

What is the meta description field you are referring to? Is this it?
https://www.screencast.com/t/Wo9unaK5z2

GP would not hide anything that Yoast displays by default.

Have you tried it with a twenty series WP theme?

This archived topic is closed to new replies.