22WordPress的标志丰富的片段代码为论文主题

为了回应一个 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 (即. 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 下面
  4. Change a Thesis setting for showing author on teasers in the options – 论文: Design Options: Teasers: Teaser Display Options: 蜱 “author name
  5. Change a Thesis setting for linking author in options – 论文: 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

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

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

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=”我”

$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

$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

发现这个有用? 请不要让我们知道通过下降到低于评论. 如果您想订阅,请使用菜单上的订阅链接右上方. 您还可以通过使用下面的链接社会分享这与你的朋友. 干杯.

发表评论

22 条评论

的gravatar乔恩·斯凯夫

是的 – 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!

回复
的gravatarTodd

谢谢乔恩. Brilliant fix. The Thesishcard 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.

回复
的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.

Ŧ

回复
的gravatar乔恩·斯凯夫

I think you’ve mixed up your rel=”我” and rel=”作者” tags a bit

You should only have a single rel=”我” 链接 – from your author page to your google profile. everywhere else you should have rel=”作者” 标签. On your homepage each post has aby Wouter de Jonglink which points (正确地) to your author page ), but you have rel=”我” on these links. It should be rel=”作者”

Once you change these rel=”我” links into rel=”作者” I think it will all workas it stands you’ve got multiple rel=”我” links on your author page, most of them back to itself and only 1 (正确地) pointing to your google profile. I think this is confusing the snippet tool

回复
的gravatarSante

乔恩喜, it worked perfectlyI 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 tolittermy themes 🙂

Thanks for the tip 🙂

回复
的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….

回复
的gravatararafinshaon

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

警告: 缺少必填字段 “更新”.
警告: 至少一个字段必须为hCard的设置.
警告: 缺少必填字段 “姓名 (FN)”.

do i have to wait for few days for crawling?

回复
的gravatar乔恩·斯凯夫

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 themelike adding extra files or using a child theme?

回复
的gravatar乔恩·斯凯夫

抱歉 – 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.

回复
的gravatarEko Y

谢谢, 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 : 内容, robots, descriptions, keywords in page info..How to get this snippet?
Thank You..

回复
的gravatar乔恩·斯凯夫

Most of that comes from using a semantic HTML5 theme for wordpress combined with the Yoast 插件. 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.

回复