I need to display Yoast SEO (wpseo plugin) category description template inside my archive template.
I need to display this on my archive template:
My site %%term_title%%. In category %%term_title%%.
Is this possible to achieve? If so, how?
OK! I found one answer that resolves my problem perfectly, here.
This is the code:
Get WPSEO title and description for category, taxonomy archives, pages, posts
// access wpseo_frontend class and get the seo title and seo description for output on archive pages
if ( class_exists( 'WPSEO_Frontend' ) ) {
$wpseo_object = WPSEO_Frontend::get_instance();
$headline = $wpseo_object->title( false );
$intro_text = $wpseo_object->metadesc( false );
}
$headline = sanitize_text_field( $headline );
$intro_text = sanitize_text_field( $intro_text );
// these should work if not archives
# $headline = get_post_meta( $post->ID, '_yoast_wpseo_title', true );
# $intro_text = get_post_meta( $post->ID, '_yoast_wpseo_metadesc', true );
Many thanks to Chuck Reynolds!