Wordpress shortcode for tag list

蓝咒 提交于 2019-12-08 07:06:38

问题


I need to insert tags (of the post) inside post in the exact place. (default: they go after)

As I understand the only way is to use shortcode and write its description in functions. I think its an easy one including "print $tags_list", but I haven't managed to write the whole piece of code needed.
Can you help me? Or advise another way to solve my problem?
PS: Maybe another way is to insert tag code inside post, but wordpress editor doesn't understand


回答1:


You don't really need a shortcode unless the position changes per post.

To render tags in your template (you could just move the code):

 <?php the_tags(); ?>

If you wanted to make a shortcode:

function sc_taglist(){

    return get_the_tag_list();
}
add_shortcode('tags', 'sc_taglist');

And use [tags]



来源:https://stackoverflow.com/questions/28202455/wordpress-shortcode-for-tag-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!