Skip to content

Instantly share code, notes, and snippets.

@jeherve
Created August 25, 2011 09:48
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 jeherve/1170344 to your computer and use it in GitHub Desktop.
Save jeherve/1170344 to your computer and use it in GitHub Desktop.
Add schema information to WordPress loop
<div itemscope itemtype="http://schema.org/Article" class="content">
<h1 itemprop="name"><?php the_title(); ?></h1>
<div class="entry-content">
<?php
if ( has_post_thumbnail() )
the_post_thumbnail( 'single-post-thumbnail', array( 'itemprop' => 'image' ) );
else
echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/default_thumb1.jpg" class="attachment wp-post-image" />';
?>
<?php if( strpos(get_the_content(), '<span id="more-') ) : ?>
<div class="postintro" itemprop="description">
<?php global $more; $more=0; the_content(''); $more=1; ?>
</div>
<?php endif; ?>
<?php the_content('', true); ?>
</div><!-- .entry-content -->
</div><!-- .content -->
@braddalton
Copy link

Why not filter the post class

@jeherve
Copy link
Author

jeherve commented Jan 21, 2022

This is from 11 years ago, so I wouldn't really worry about it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment