Home / functions.php / Add a custom class to the_tags
  • Add a custom class to the_tags

    add-a-custom-class-to-the_tags

    Adding this snippet to the functions.php of your wordpress theme will add a custom class to links output by the_tags template tag.

    wordpress snippet : PHP

    <>
    function add_class_the_tags($html){
        $postid = get_the_ID();
        $html = str_replace('<a','<a class="wpsnipp"',$html);
        return $html;
    }
    add_filter('the_tags','add_class_the_tags',10,1);
    

    ( WordPress codex functions, hooks, in this snippet. )

    the_tags, get_the_ID, the_ID, add_filter, wp,

Build a better with wpsnipp.com

Weekly snippets, themes, deals coupons roundup.

x No Thanks