开发者

How to Assign rel="cat" and rel="tag" in Breadcrumbs

Currently I'm building a new WP theme. I'm a designer and have only basic knowledge of PHP. S开发者_开发技巧o for breadcrumbs, I used Dimox's script.

But from an SEO point of view, I want to add the rel="cat" and rel="tag" to categories and tag links respectively in the breadcrumbs. I asked him, but he couldn't provide a solution. So if any WP developer can help me out in this it would be great.

Here is the Exact piece of code for the category link.

else {
        $cat = get_the_category(); $cat = $cat[0];
        echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
        echo $before . get_the_title() . $after;
      }

So I want to assign a rel="cat" tag to the category link which is created by the get_the_category function.


Change line 45 of the original code to:

if ($cat->parent != 0){
    $parents = array_reverse(get_ancestors($cat->cat_ID, 'category'));
    foreach($parents as $parent_id){
        $parent = get_category($parent_id);
        echo '<a rel="cat" href="'.get_category_link($parent->cat_ID).'" title="'.esc_attr(sprintf(__( "View all posts in %s" ), $parent->name)).'">'.$parent->name.'</a> '.$delimiter.' ';
    }
}

echo '<a rel="cat" href="'.get_category_link($cat->cat_ID).'" title="'.esc_attr(sprintf(__( "View all posts in %s" ), $cat->name)).'">'.$cat->name.'</a> '.$delimiter.' ';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜