`
$metadescription = wp_trim_words( get_the_content(), 55, '');
add_post_meta($post_id, 'meta_description', '$metadescription', true);`
but output is $metadescription
anyone help me please
`$metadescription = wp_trim_words( get_the_content(), 55, ”);
add_post_meta($post_id, ‘meta_description’, ‘$metadescription’, true);“
3
Answers
Try out the below code:
For the variable, you don’t need to use
''
for that.First, make sure that
get_the_content
is returning the content you want and$meta_description
isn’t null.Try This:
I found the best option, please try this.