wright_jamie
Member
Posted 5 months ago #
I am using the code below to add FB Open Graph Meta Tags. It all works apart from the description, which returns a blank string from the 'get_the_excerpt()'.
Has anyone come across this before? Any help would be greatly appreciated.
Thanks
Jamie
[Code moderated as per the Forum Rules. Please use the pastebin]
wright_jamie
Member
Posted 5 months ago #
I should have said, I've tried with both get_the_excerpt($post->ID) and get_the_excerpt()
wright_jamie
Member
Posted 5 months ago #
//Lets add Open Graph Meta Info
function insert_fb_in_head() {
global $post;
if ( !is_singular()) //if it is not a post or a page
return;
echo '<meta property="og:description" content="' .get_the_excerpt($post->ID). '"/>';
}
add_action( 'wp_head', 'insert_fb_in_head', 5 );