0

I'm trying to list the post's tags without success. Anyone know what can be happening here? The code just stops there, last line loading is the tag. I've tried it with foreach, for, and implode, within an if statement and also without.

<?php 
    $tags = get_tags();
    if( count( $tags) > 0) {
        echo '<div id="etiquetas">';
        echo '<ul class"tags">';
        foreach($tags as $tag){
            echo "<li>". $tag ."</li>";
          }
        echo '</ul>';
        echo '</div>';
    }
    ?>
  • Any error messages? Did you try a echo "<pre>" . print_r($tags) . "</pre>"; right after the get_tags function? (You could also put a die() in there to ensure that processing stops.) The print_r function (with <pre>) will print out the contents of the array, so you can see exactly what is being returned. – Rick Hellewell Sep 17 '17 at 22:15
0

Thanks for your answer. I figured it out, i was using the wrong function.

<?php 
    $tags = get_the_tag_list($before = '<li>', $sep = '</li><li>' $after = '</li>');
    if( count( $tags) > 0) {
    echo '<div id="etiquetas">';
    echo '<ul class"tags">';
    echo $tags;
    echo '</ul>';
    echo '</div>';
    }
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.