Skip to content

Instantly share code, notes, and snippets.

@erickacevedor
Created October 24, 2019 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erickacevedor/3804723be3a84a34d0554502d9252b1c to your computer and use it in GitHub Desktop.
Save erickacevedor/3804723be3a84a34d0554502d9252b1c to your computer and use it in GitHub Desktop.
Structured data markup ready for WordPress single file.
<?php $autorname; ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$authorfname = get_the_author_meta('first_name');
$authorlname = get_the_author_meta('last_name');
$autorname = "{$authorfname} {$authorlname}";
?>
<?php endwhile; ?>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"name": "<?php the_title(); ?>",
"author": {
"@type": "Person",
"name": "<?php echo $autorname; ?>"
},
"datePublished": "<?php echo get_the_date('Y-m-d'); ?>",
"articleSection": "blog",
"url": "<?php the_permalink(); ?>",
"publisher": {
"@type": "Organization",
"name": "OrganizationName"
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment