Google Yapısal Veri(Rich Snippets) Kullanmak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// yapısal veri | |
add_action( 'wp_head', 'google_yapisal_veri' ); | |
function google_yapisal_veri(){ | |
if (is_single()){ // Sadece tekil yazı sayfalarına ekler | |
global $post; | |
$post_id = get_the_ID(); | |
setup_postdata( $post ); | |
?> | |
<!-- Google Yapısal Veri. --> | |
<script type="application/ld+json"> | |
{ | |
"@context" : "http://schema.org", | |
"@type" : "Article", | |
"name" : "<?php the_title();?>", | |
"author" : { | |
"@type" : "Person", | |
"name" : "<?php the_author();?>" | |
}, | |
"datePublished" : "<?php the_time('Y'); ?>-<?php the_time('m'); ?>-<?php the_time('j'); ?>", | |
"image" : "<?php echo the_post_thumbnail_url('full') ?>", | |
"articleBody" : "<?php echo esc_attr(get_the_content());?>", | |
"url" : "<?php the_permalink();?>" | |
} | |
</script> | |
<?php | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment