阿里云服务器

文章标签对于seo来说非常的重要,我们也可以通过标签对相同类型的文章进行分类。wordpress网站有默认的文章标签功能,我们只需要调用出来就可以了。

wordpress默认的标签函数为:the_tags

在系统文件:wp-includes/category-template.php 里面

/**
 * Retrieve the tags for a post.
 *
 * @since 2.3.0
 *
 * @param string $before Optional. Before list.
 * @param string $sep Optional. Separate items using this.
 * @param string $after Optional. After list.
 */function the_tags( $before = null, $sep = ', ', $after = '' ) {
	if ( null === $before )
		$before = __('Tags: ');

	$the_tags = get_the_tag_list( $before, $sep, $after );

	if ( ! is_wp_error( $the_tags ) ) {
		echo $the_tags;
	}}

我们能看到the_tags函数是通过调用get_the_tag_list进行数据获取。

下面给大家分享一下 the_tags 的使用实例:

第一种调用方法:

<?php the_tags(); ?>

输出的样式为:标签:XXX, XXXX

第二种方法:

<?php the_tags( '<ul><li>', '</li><li>', '</li></ul>' ); ?>

可以对调用标签进行样式编辑,根据自己的需要进行调整。

列如:

<?php the_tags('<span class="f14">', '</span><img class="dott" src="/wp-content/themes/beichuan/images/dott.png" alt=""> <span class="f14">', '</span>'); ?>

显示效果:

标签样式

相关阅读:
  • wordpress编辑框不让span过滤的方法
  • wordpress搜索为空时仍然返回结果问题
  • wordpress注册页取消邮箱的方法
  • wordpress用户头像在线调用代码
  • wordpress自动隐藏email注册,直接用户名密码注册
  • wordpress设置游客只能访问指定页面的方法
  • wordpress列表分页显示404页面的解决办法
  • wordpress页面默认排序修改的方法
  • wordpress新版本5.4 “Adderley” 发布上线,更新多项功能
  • wordpress默认编辑器功能增加的方法