• I would like to add hrecipe microformats to my blog without manually editing each post. I found a detailed description, with code, on how to do this, but part of it doesn’t quite work for my site, so I was hoping someone here might be able to help.

    The code in question uses post tags to create the hrecipe ingredient list. The problem is that the code only pulls tags that include the description “ingredient.” I would like to change it to include all tags, because I use the description field for actual descriptions that don’t necessarily use that word.

    Here is the code:

    function the_hrecipe_tags( $before = null, $sep = ', ', $after = '' ){
            if ( null === $before )
                    $before = __('Tags: ');
    
        $tags = get_the_tags();
        if (null != $tags && count($tags)>0){
            foreach ($tags as $tag){
                if(null!=($tag->description))
                    $tag_list[]= '<a class="tag '.$tag->description.'" rel="tag" href="'. get_tag_link($tag->term_id).'">'.$tag->name.'</a>';
                else
                    $tag_list[]= '<a class="tag" rel="tag" href="'. get_tag_link($tag->term_id).'">'.$tag->name.'</a>';
                }
        }
        if (isset($tag_list))
            echo $before . join($sep, $tag_list) . $after ;
    }

    I would be very grateful for any assistance.

    http://www.theveggietable.com/blog/

  • The topic ‘Adding hrecipe microformats via functions.php’ is closed to new replies.