Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode( 'post_tags_plus', 'sk_post_tags_shortcode' );
- /**
- * Produces the tag links list with each link wrapped in span.tag-slug..
- *
- * Supported shortcode attributes are:
- * after (output after link, default is empty string),
- * before (output before link, default is 'Tagged With: '),
- * sep (separator string between tags, default is ', ').
- *
- * Output passes through 'genesis_post_tags_shortcode' filter before returning.
- *
- * @since 1.1.0
- *
- * @param array|string $atts Shortcode attributes. Empty string if no attributes.
- * @return string Shortcode output
- */
- function sk_post_tags_shortcode( $atts ) {
- $defaults = array(
- 'after' => '',
- 'before' => __( 'Tagged With: ', 'genesis' ),
- 'sep' => ', ',
- );
- $atts = shortcode_atts( $defaults, $atts, 'post_tags' );
- // $tags = get_the_tag_list( $atts['before'], trim( $atts['sep'] ) . ' ', $atts['after'] );
- $tags = get_the_tags();
- //* Do nothing if no tags
- if ( ! $tags )
- return;
- foreach( $tags as $tag ) {
- // Get the ID of this tag
- $tag_id = $tag->term_id;
- // Get the URL of this tag
- $tag_link = get_tag_link( $tag_id );
- $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="tag"';
- $tags .= '<a href="' . esc_url( $tag_link ) . '" class="' . $tag->slug . '" '. $rel .'>' . $tag->name . '</a>' . $atts['sep'];
- }
- $tags = rtrim( $tags, $atts['sep'] );
- $output = sprintf( '<span %s>', genesis_attr( 'entry-tags' ) ) . $atts['before'] . $tags . $atts['after'] . '</span>';
- return apply_filters( 'genesis_post_tags_shortcode', $output, $atts );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement