Hướng dẫn sửa lỗi Google Rich Snippet cho WordPress

Một số bạn xây dựng web trên mã nguồn mở Wordpress gặp phải lỗi khi cài đặt Google AuthorShip như:

  • Warning: At least one field must be set for HatomEntry
  • Warning: Missing required field “entry-title”.
  • Warning: Missing required field “updated”.
  • Warning: Missing required hCard “author”.
  • Warning: At least one field must be set for Hcard.
  • Warning: Missing required field “name (fn)”.
Lỗi này thường thì phát sinh do cấu trúc Snippet trong single.php của theme chưa chuẩn, ta sẽ tiến hành sửa lỗi.
Đầu tiên bạn vào phần quản trị trang ( domain.com/wp-admin/) và đến phần Giao diện ( Appearence) => Editor => Single.php

1/ Sửa lỗi : Missing required field “entry-title”

Các theme thông thường sẽ có đoạn code sau :
1
<h1 class="title single-title"><?php the_title(); ?></h1>
Hãy thay nó với code bên dưới đây

<h1 class="title single-title entry-title"><?php the_title(); ?></h1>

2/ Sửa lỗi : Missing required hCard “author”Missing required field “name (fn)”

Bước này sẽ sửa cả 2 lỗi. Tìm đoạn :
<span class="theauthor"><?php the_author_posts_link(); ?></span>
hoặc

<span class="theauthor"><?php the_author(); ?></span>
Sửa lại thành





<span class="vcard author">
 
<span class="fn"><?php the_author_posts_link(); ?></span>
 
 </span>
hoặc





<span class="vcard author">
 
 <span class="fn"><?php the_author(); ?></span>
 
</span>

3/ Sửa lỗi : Fix Missing required field “updated”

Tìm đoạn code sau :

<span class="post_date"><?php the_time('j F,Y'); ?></span>
Thêm vào thuộc tính  “date updated” , khi đó code có dạng như sau :

<span class="post_date date updated"><?php the_time('j F,Y'); ?></span>

Sau khi hoàn thành bạn sẽ kiểm tra lại trên Snippet trên Google: http://www.google.com/webmasters/tools/richsnippets
 Newshare Blog chúc bạn thành công!
Share on Google Plus

About Unknown

    Blogger Comment
    Facebook Comment

0 nhận xét:

Đăng nhận xét