Facebook og title , image, and description adding in wordpress without plugin:

In ‘wp-head’ hook we need to set the og:title, descripts etc…

add_action(‘wp_head’, ‘og_details’);

function og_details() {
global $post;

if(is_single()) {
if(has_post_thumbnail($post->ID)) {
$ogimg =get_the_post_thumbnail_url($post->ID,’full’);
}
if($desc = $post->post_content) {
$desc = strip_tags($desc);
$desc= str_replace(“”, “‘”, $desc);
}
?>

<meta property=”og:title” content=”<?php echo the_title(); ?>”/>
<meta property=”og:description” content=”<?php echo $desc; ?>”/>
<meta property=”og:image” content=”<?php echo $ogimg; ?>”/>

<?php
}
}
?>