WordPress function the_tags acquired by tag use analytical methods

  We know that there is a wordpress the_tags function can get to all tags article settings, and output in the form you want. In the article page output label helps in the distribution chain, improve SEO results. Display label name and link to the tag in the template, if the current page is not displayed in label-free, this function must be used in WordPress main loop . It is that we can get to a place of global variables post, usually for the article page with the article list page.

  the_tags function is located wp-includes / category-template.php file:

/**
 * 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;
	}
}

  We can see the_tags function is to obtain data by calling get_the_tag_list.

  Use function

<PHP the_tags (the before $, $ sep, the After $);??> 
// the before $ 
content // before displaying output, usually label the container in which the link HTML tags. 
$ sep // 
// used to separate content, you may be empty, look at the specific effect of the following diagram. 
the After $ // 
// display content after the tag, usually label the container in which the link HTML tags.

  Examples of Use

  The default method

<?php the_tags(); ?>
等同于:<?php the_tags( 'Tags: ', ', ', '' ); ?>

  Get: Tags: XXX, XXXX

  another one

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

  

Guess you like

Origin www.cnblogs.com/ytkah/p/12094970.html