I have a code that call get_the_title()
and it works, but get_the_excerpt()
return empty. How can i make it work?
This code is inside a plugin called "WP Facebook Open Graph protocol". Here's the part i want to change:
if (is_singular('post')) {
if (has_excerpt($post->ID)) {
echo "\t<meta property='og:description' content='".esc_attr(strip_tags(get_the_excerpt($post->ID)))."' />\n";
}else{
echo "\t<meta property='og:description' content='". [?] ."' />\n";
}
}else{
echo "\t<meta property='og:description' content='".get_bloginfo('description')."' />\n";
}
Here, has_excerpt
always fail, and get_the_excerpt($post->ID)
don't work anymore (deprecated).
So, how can i display the excerpt there?
ps: I'm using "Advanced Excerpt" plugin as well
my_excerpt($post->post_content, get_the_excerpt())
and using themy_excerpt()
function from wordpress.stackexchange.com/questions/6961/…the_post()
(it works on single post template too) function before you callget_the_excerpt()
it will setup necessary data for you.