php - Wordpress yoast seo plugin - parse snippet var in meta description

I am using this function to get the yoast meta description$metadesc = get_post_meta( $id, '_yoast_wpseo_metadesc�

I am using this function to get the yoast meta description

$metadesc = get_post_meta( $id, '_yoast_wpseo_metadesc', true );

But it is returning the snippet variable.

From transitional styles %%title%% with soft color palettes to bold

How can I parse that %%variable%%?

I am using this function to get the yoast meta description

$metadesc = get_post_meta( $id, '_yoast_wpseo_metadesc', true );

But it is returning the snippet variable.

From transitional styles %%title%% with soft color palettes to bold

How can I parse that %%variable%%?

Share Improve this question asked Mar 21, 2019 at 14:37 baskinbaskin 313 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Ok here is how I parsed the snippets in case anyone else needs to know

$id = get_the_ID();

$post         = get_post( $id, ARRAY_A );
$yoast_title = get_post_meta( $id, '_yoast_wpseo_title', true );
$yoast_desc = get_post_meta( $id, '_yoast_wpseo_metadesc', true );

$metatitle_val = wpseo_replace_vars($yoast_title, $post );
$metatitle_val = apply_filters( 'wpseo_title', $metatitle_val );

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

echo $metatitle_val;
echo "<br>";
echo $metadesc_val;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745665708a4639110.html

相关推荐

  • php - Wordpress yoast seo plugin - parse snippet var in meta description

    I am using this function to get the yoast meta description$metadesc = get_post_meta( $id, '_yoast_wpseo_metadesc�

    4小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信