In my theme has one shortcode tags to display tags of post and function to load content post. But in function doesn’t include shortcode tag. Now I want to add it to function but i don’t know how to do it. Hope everyone help me out. Thank in advance.
Shortcode tag
function wwl_post_tags( $atts ) {
if( $tags = get_the_tag_list( '', ', ' ) ) {
$defaults = array(
'before' => __( 'Từ khóa: ', 'icy' ),
'after' => '. ',
);
$atts = shortcode_atts( $defaults, $atts );
return sprintf( '%1$s<span class="entry-tags">%2$s</span>%3$s',
$atts['before'],
$tags,
$atts['after']
);
}
}
add_shortcode( 'post_tags', 'wwl_post_tags' );
Function to load content post
function wwl_post_content() {
global $more;
if ( ! is_single() ) {
$more = 0;
}
do_action( 'wwl_before_post_content' ); // Hook
if ( ! is_single() && of_get_option('post_content') == 2 || is_search() ) :
?>
<div class="entry-summary">
<?php wwl_thumbnail(); ?>
<?php the_excerpt(); ?>
<div class="clearfix"></div>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php wwl_thumbnail(); ?>
<?php the_content( '', false, '' ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'icy' ), 'after' => '</div>' ) ); ?>
<div class="clearfix"></div>
</div><!-- .entry-content -->
<?php endif;
}
Another option is to use the do_shortcode() function. This will make WordPress run the shortcode as if it was in the content editor.
So where you want your post tags to appear just put.
Paste
[post_tags]
into your post body via the post editor on the backend.See: http://codex.wordpress.org/Shortcode_API
If you want to do it automatically you could put a filter on
the_content
(untested):