22Wordpress LogoRich Snippets Code for Thesis Theme

In response to a query by Darko Kovancives on my previous article about fixing Rich Snippets code for the Mystique theme we have resolved the same issues with the Thesis theme.  Details of the changes required are below.

Before the file edits you need to carry out various other changes and tasks

  1. Get a google profile (i.e. a google+ account)
  2. Add the address of your site (e.g. https://diymediahome.org) to your google+ profile, as a public link
  3. Get your google plus ID and use it in place of mine in file edit number 5 below
  4. Change a Thesis setting for showing author on teasers in the options – Thesis: Design Options: Teasers: Teaser Display Options: Tick “author name”
  5. Change a Thesis setting for linking author in options – Thesis: Design Options: Display Options: Bylines: “Link author names to archives”

Now do the file edits as follows

1. Edit line 151 in content.php to nest the fn span inside a vcard span

from

echo __('by', 'thesis') . " <span class=\"author vcard$fn\">$author</span>";

to

echo __('by', 'thesis') . " <span class=\"vcard\"><span class=\"author $fn\">$author</span></span>";

2. Edit line 114 in content.php to provide updated date as well as published date

from

if ($date)
echo '<abbr class="published" title="' . get_the_time('Y-m-d') . '">' . get_the_time(get_option('date_format')) . '</abbr>';

to

if ($date){
if(get_the_date()!=get_the_modified_date()){
echo '<abbr class="published" title="' . get_the_time('Y-m-d') . '">' . get_the_time(get_option('date_format')) . '</abbr>.  Updated <abbr class="updated" title="' . get_the_modified_time('Y-m-d') . '">' . get_the_modified_time(get_option('date_format')) . '</abbr>';
}
else{
echo '<abbr class="published updated" title="' . get_the_time('Y-m-d') . '">' . get_the_time(get_option('date_format')) . '</abbr>';
}
}

3. Edit line 81 in teasers.php to include updated date

from

echo '<abbr class="teaser_date published" title="' . get_the_time('Y-m-d') . '">' . get_the_time($use_format) . "</abbr>\n";

to

if(get_the_date()!=get_the_modified_date()) echo '<abbr class="teaser_date published" title="' . get_the_time('Y-m-d') . '">' . get_the_time($use_format) . '</abbr><abbr class="teaser_date updated" title="' . get_the_modified_time('Y-m-d') . '"><span class="value-title" title="'.get_the_modified_time($use_format).'"></span></abbr>'."\n";
else echo '<abbr class="teaser_date published updated" title="' . get_the_time('Y-m-d') . '">' . get_the_time($use_format) . "</abbr>\n";

4. Edit the author href code on line 144 of content.php to add rel=”me”

from

$author = '<a href="' . get_author_posts_url(get_the_author_ID()) . '" class="url fn"' . $nofollow .'>' . get_the_author() . '</a>';

to

$author = '<a rel="me" href="' . get_author_posts_url(get_the_author_ID()) . '" class="url fn"' . $nofollow .'>' . get_the_author() . '</a>';

5. Edit line 308 in content.php to insert google account link

from

$output .= "$tab\t<h1>" . apply_filters('thesis_archive_intro_headline', get_author_name($wp_query->query_vars['author'])) . "</h1>\n"; #wp

to

$output .= "$tab\t<h1><a rel=\"me\" href=\"http://plus.google.com/104657888470728381512/\">" . apply_filters('thesis_archive_intro_headline', get_author_name($wp_query->query_vars['author'])) . "</a></h1>\n"; #wp

What do you think? Drop us a comment below! If you would like to subscribe please use the subscribe link on the menu at the top right. You can also share this with your friends by using the social links below. Cheers.

Leave a Reply

22 Comments

gravatarMim Akter

very helpful website. it is big useful for us. thanks for sharing.

Reply
gravatarJon Scaife

Yes – I’ve had some syntax corrupted by the wordpress code editor and by a plugin. I’ve hopefully resolved this now and will be double checking the code on all posts over the weekend. Sorry about that!

Reply
gravatarTodd

Thanks Jon. Brilliant fix. The Thesis’ hcard errors cleaned up nicely.
We are having a related issue which maybe you’ll know the answer for. We have a some coding generating the hrecipe formatting and can see the markups when inspecting the post elements, but the rich snippet tool isn’t picking it up at all. The developer has no problems getting picked up on her site and others she has built out, but for some reason it isn’t getting picked up on a Thesis theme.

Don’t know if this is in your roundhouse, but if you could take a look that would be awesome.

Here is a post of ours with the markup: Roasted Strawberry Muffin
Here is one of hers with the markup: Applesauce Muffins

Thanks again for the previous fix and for any help you can offer.

Reply
gravatarTodd

I figured out the answer. The recipe was wrapped in a blockquote tag. I changed that to a div tag and everything ran through perfect.

Thanks again on the previous hcard coding.

T

Reply
gravatarJon Scaife

I think you’ve mixed up your rel=”me” and rel=”author” tags a bit

You should only have a single rel=”me” link – from your author page to your google profile. everywhere else you should have rel=”author” tags. On your homepage each post has a “by Wouter de Jong” link which points (correctly) to your author page ), but you have rel=”me” on these links. It should be rel=”author”

Once you change these rel=”me” links into rel=”author” I think it will all work – as it stands you’ve got multiple rel=”me” links on your author page, most of them back to itself and only 1 (correctly) pointing to your google profile. I think this is confusing the snippet tool

Reply
gravatarSante

Hi Jon, it worked perfectly – I didn’t include items 4 and 5 from your list as they are not essential to validate the rich snippet and I’m not betting on Google+ just yet so I don’t want to “litter” my themes 🙂

Thanks for the tip 🙂

Reply
gravatararafinshaon

having trouble @ Jon Scaife i’m not getting exactly the same code into content.php file. I’m using thesis 1.8.2. waiting 4 your response….

Reply
gravatarJon Scaife

You might have to search for similar code on slightly different line numbers. If you send me your content.php I’ll have a look

Reply
gravatararafinshaon

i did this exactly. after doing this my Authorship markup got verified but unfortunately I’m getting below errors .

Warning: Missing required field “updated”.
Warning: At least one field must be set for Hcard.
Warning: Missing required field “name (fn)”.

do i have to wait for few days for crawling?

Reply
gravatarJon Scaife

What’s your site address? Which page are you getting the errors on? The homepage, a post or both? Have you made any other modifications to the theme – like adding extra files or using a child theme?

Reply
gravatarJon Scaife

Sorry – my fault. I’ve figured it out. The code had got mangled by wordpress. I think when I update the post wordpress processes some of the code and takes some of the classes out which makes it disfunctional. I’ve corrected it. Please give it a try now.

Reply
gravatarEko Y

Thanks, very useful info. But, how to add meta tags information like this blog? It looks if i do right click in browser >> view page info. There are many information on general tab. Like Author, Viewport Etc. My blog is just contain : content, robots, descriptions, keywords in page info..How to get this snippet?
Thank You..

Reply
gravatarJon Scaife

Most of that comes from using a semantic HTML5 theme for wordpress combined with the Yoast SEO plugin. I also have various meta files like humans.txt and robots.txt. Have a look at the wordpress guide for loads of information about improving your wordpress setup.

Reply