header: add opengraph support

Fix #14
This commit is contained in:
Kazhnuz 2018-10-27 14:11:47 +02:00
parent dea5ea1d67
commit e10b67cc15
3 changed files with 16 additions and 0 deletions

15
components/opengraph.php Normal file
View file

@ -0,0 +1,15 @@
<?php if ( is_single() ) { ?>
<?php if(!has_post_thumbnail( $post->ID )) {
$image = get_template_directory_uri() . "/img/default-preview.png";
} else {
$image = get_the_post_thumbnail_url();
}
?>
<meta property='og:url' content='<?php echo get_permalink(); ?>'/>
<meta property='og:type' content='article'/>
<meta property='og:title' content='<?php wp_title(''); ?>'/>
<meta property='og:site_name' content='<?php bloginfo('name'); ?>'/>
<meta property='og:image' content='<?php echo $image ?>'/>
<meta property='og:description' content='<?php the_excerpt(); ?>'/>
<?php } ?>

View file

@ -11,6 +11,7 @@
<?php endif; ?>
<?php wp_head(); ?>
<?php include(TEMPLATEPATH . '/components/opengraph.php'); ?>
<!-- mon icon -->
<link rel="shortcut icon" href="img/favicon.png">

BIN
img/default-preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB