Created
April 28, 2021 16:05
-
-
Save pelukho/09e037949d2b5c83c80d30087a5b13c7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function dtrm_add_article_microdata() { | |
if ( 'post' !== get_post_type() && ! is_singular() ) { | |
return; | |
} | |
$current_post_id = get_queried_object_id(); | |
?> | |
<script type=application/ld+json> | |
{ | |
"@context" : "http://schema.org", | |
"@type" : "Article", | |
"headline" : "<?php echo esc_html( get_the_title( $current_post_id ) ); ?>", | |
"articleSection" : "нужно уточнить что это вообще", | |
"image" : ["<?php echo get_the_post_thumbnail_url( $current_post_id, 'full' ); ?>"], | |
"datePublished" : "<?php echo get_the_date( 'c' ); ?>", | |
"dateModified" : "<?php echo get_the_modified_date( 'c' ); ?>", | |
"publisher" : { | |
"@type" : "Organization", | |
"name" : "Dataroom-Providers.org", | |
"logo" : { | |
"type" : "ImageObject", | |
"url" : "<?php echo get_stylesheet_directory_uri() . '/path/to/logo'; ?>" | |
} | |
}, | |
"description" : "<?php echo get_the_excerpt( $current_post_id ); ?>" | |
} | |
</script> | |
<?php | |
} | |
add_action( 'wp_footer', 'dtrm_add_article_microdata' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment