Support » Themes and Templates » Conditional "a" tag

  • lifeisnoyoke


    I need to adjust shortcode php file. I need link to a tag only if there is a tag description and tool tip. Currently, all tags listed provide links.

    For example, I need there to be links for “blender”, “stevia”, and “almond milk” because they have tag descriptions (info for stuff people need to buy). I do not want links to tags like “apples”. Here’s the example:

    Here’s the code:

    if($ingridients) {
            $output .= '<h4>'.__("Ingredients:", 'purepress').'</h4><ul class="ingredients">';
            foreach ($ingridients as $key => $value ) {
                if($value['note']=='separator') {
                    $output .= '<li class="separator">'.$value['name'].'</li>' ;
                } else {
                    $tag_id = get_tag_id_by_name($value['name']);
                    if($tagdesc) $output .= '<div class="tooltip">'.get_term_photo_by_id($tag_id).$tagdesc.'</div>';
                      $output .='</li>';
    		if($recipe_tooltip == 'yes') { $tagdesc = tag_description($tag_id); }
                    $output .= '<li class="ingredient ingridients-cont'; if($tagdesc) $output .= ' hasdesc ';
                    $output .= '"itemprop="ingredients"><a href="'.get_tag_link($tag_id).'">'.$value['name'].'</a> - <span>'.$value['note'].'</span>';
            $output .= "</ul>";

  • The topic ‘Conditional "a" tag’ is closed to new replies.