admin管理员组文章数量:1122832
In my theme I use <?php echo the_category(', '); ?>
to get the categories, separates by comma, with links to them. But those links have no title attribute. Is there any way to get them?
In my theme I use <?php echo the_category(', '); ?>
to get the categories, separates by comma, with links to them. But those links have no title attribute. Is there any way to get them?
- What do you need it for? A title attribute for a link that already has the same text is redundant, and it doesn't actually help accessibility or SEO. – Jacob Peattie Commented Nov 25, 2018 at 7:40
- What should that title attr contain? – Krzysiek Dróżdż Commented Nov 25, 2018 at 8:39
- I wanna reduce SEO title and alt errors... So alt and title could contain just name of the category. But now I think it's not worth of the work... – Damian Commented Nov 25, 2018 at 21:31
1 Answer
Reset to default 0There are no filters in get_the_category_list
function, that will allow you to add title attribute to those links, so you'll have to write your own code for that...
<?php
$categories = get_the_category();
foreach ( $categories as $i => $cat ) :
if ( $i ) echo ', ';
?>
<a href="<?php echo esc_url( get_category_link( $category->term_id ) ); ?>" ><?php echo $category->name; ?></a>
<?php endforeach; ?>
本文标签: categoriesHow to get thecategory(3939) with link quottitlequot attribute
版权声明:本文标题:categories - How to get the_category(', ') with link "title" attribute 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736292835a1929018.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论