WordPress.org

Ready to get started?Download WordPress

Forums

Conditional "a" tag (1 post)

  1. lifeisnoyoke
    Member
    Posted 1 year ago #

    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: http://lifeisnoyoke.com/quinoa-kugel-muffins/

    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>";
    
        }

Topic Closed

This topic has been closed to new replies.

About this Topic