List all the tags in a WordPress blog










-2















I need to list all the tags with at least 1 published post in a WordPress blog.



The list is about the full blog and not related to the current post.



What code would you use?










share|improve this question

















  • 3





    What code did you try? Did you at least google something like 'Wordpress show all tags'?

    – RST
    Sep 25 '16 at 9:13






  • 2





    Possible duplicate of get all tags of published posts Wordpress

    – MarZab
    Sep 25 '16 at 9:21















-2















I need to list all the tags with at least 1 published post in a WordPress blog.



The list is about the full blog and not related to the current post.



What code would you use?










share|improve this question

















  • 3





    What code did you try? Did you at least google something like 'Wordpress show all tags'?

    – RST
    Sep 25 '16 at 9:13






  • 2





    Possible duplicate of get all tags of published posts Wordpress

    – MarZab
    Sep 25 '16 at 9:21













-2












-2








-2








I need to list all the tags with at least 1 published post in a WordPress blog.



The list is about the full blog and not related to the current post.



What code would you use?










share|improve this question














I need to list all the tags with at least 1 published post in a WordPress blog.



The list is about the full blog and not related to the current post.



What code would you use?







php wordpress tags






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 25 '16 at 9:07









maryamarya

4818




4818







  • 3





    What code did you try? Did you at least google something like 'Wordpress show all tags'?

    – RST
    Sep 25 '16 at 9:13






  • 2





    Possible duplicate of get all tags of published posts Wordpress

    – MarZab
    Sep 25 '16 at 9:21












  • 3





    What code did you try? Did you at least google something like 'Wordpress show all tags'?

    – RST
    Sep 25 '16 at 9:13






  • 2





    Possible duplicate of get all tags of published posts Wordpress

    – MarZab
    Sep 25 '16 at 9:21







3




3





What code did you try? Did you at least google something like 'Wordpress show all tags'?

– RST
Sep 25 '16 at 9:13





What code did you try? Did you at least google something like 'Wordpress show all tags'?

– RST
Sep 25 '16 at 9:13




2




2





Possible duplicate of get all tags of published posts Wordpress

– MarZab
Sep 25 '16 at 9:21





Possible duplicate of get all tags of published posts Wordpress

– MarZab
Sep 25 '16 at 9:21












3 Answers
3






active

oldest

votes


















1














$tags = get_tags();
$html = '<ul>';
foreach ( $tags as $tag )
if($tag->slug != "migliori")
$tag_link = get_tag_link( $tag->term_id );
$html .= "<li><a href='$tag_link' class='$tag->slug'>";
$html .= "$tag->name</a></li>";



$html .= '</ul>';
echo $html;


This works.






share|improve this answer






























    1














    I tried this and worked for me.



    <?php
    $tags = get_tags();
    if ($tags)
    ?><ul class="tags"><?php
    foreach ($tags as $tag)
    echo '<li><a href="' . get_tag_link( $tag->term_id ) . '"
    title="' . sprintf( __( "View all posts in %s" ), $tag-
    >name ) . '" ' . '>' . $tag->name.'</a></li>';

    echo '<li><a href="#">View All</a><span class="arrow"></span>
    </li>'; ?></ul>
    <?php ?>





    share|improve this answer






























      0














      edit this code and work for me !!!



      <ul class="tags">


      <?php

      $tags = get_tags('post_tag'); //taxonomy=post_tag
      //echo "<pre>";
      //print_r($tags);
      //var_dump($tags);
      if ( $tags ) :
      foreach ( $tags as $tag ) : ?>
      <li><a class="tag" href="<?php echo esc_url( get_tag_link( $tag->term_id ) ); ?>" title="<?php echo esc_attr( $tag->name ); ?>"><?php echo esc_html( $tag->name ); ?></a></li>
      <?php endforeach; ?>
      <?php endif; ?>
      </ul>





      share|improve this answer

























      • Can you add some explanation to this code? To me, it looks like a scrambled copy of other answers

        – Nico Haase
        Nov 14 '18 at 9:41











      • But this code show all tags. But i showing particular single post tag listing. can you use this code. <?php the_tags( '<ul class="tags"> <li class="tag">', '</li><li class="tag">', '</li></ul>' ); ?>

        – Purnendu Sarkar
        Nov 15 '18 at 7:13











      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39685167%2flist-all-the-tags-in-a-wordpress-blog%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      $tags = get_tags();
      $html = '<ul>';
      foreach ( $tags as $tag )
      if($tag->slug != "migliori")
      $tag_link = get_tag_link( $tag->term_id );
      $html .= "<li><a href='$tag_link' class='$tag->slug'>";
      $html .= "$tag->name</a></li>";



      $html .= '</ul>';
      echo $html;


      This works.






      share|improve this answer



























        1














        $tags = get_tags();
        $html = '<ul>';
        foreach ( $tags as $tag )
        if($tag->slug != "migliori")
        $tag_link = get_tag_link( $tag->term_id );
        $html .= "<li><a href='$tag_link' class='$tag->slug'>";
        $html .= "$tag->name</a></li>";



        $html .= '</ul>';
        echo $html;


        This works.






        share|improve this answer

























          1












          1








          1







          $tags = get_tags();
          $html = '<ul>';
          foreach ( $tags as $tag )
          if($tag->slug != "migliori")
          $tag_link = get_tag_link( $tag->term_id );
          $html .= "<li><a href='$tag_link' class='$tag->slug'>";
          $html .= "$tag->name</a></li>";



          $html .= '</ul>';
          echo $html;


          This works.






          share|improve this answer













          $tags = get_tags();
          $html = '<ul>';
          foreach ( $tags as $tag )
          if($tag->slug != "migliori")
          $tag_link = get_tag_link( $tag->term_id );
          $html .= "<li><a href='$tag_link' class='$tag->slug'>";
          $html .= "$tag->name</a></li>";



          $html .= '</ul>';
          echo $html;


          This works.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 25 '16 at 10:40









          maryamarya

          4818




          4818























              1














              I tried this and worked for me.



              <?php
              $tags = get_tags();
              if ($tags)
              ?><ul class="tags"><?php
              foreach ($tags as $tag)
              echo '<li><a href="' . get_tag_link( $tag->term_id ) . '"
              title="' . sprintf( __( "View all posts in %s" ), $tag-
              >name ) . '" ' . '>' . $tag->name.'</a></li>';

              echo '<li><a href="#">View All</a><span class="arrow"></span>
              </li>'; ?></ul>
              <?php ?>





              share|improve this answer



























                1














                I tried this and worked for me.



                <?php
                $tags = get_tags();
                if ($tags)
                ?><ul class="tags"><?php
                foreach ($tags as $tag)
                echo '<li><a href="' . get_tag_link( $tag->term_id ) . '"
                title="' . sprintf( __( "View all posts in %s" ), $tag-
                >name ) . '" ' . '>' . $tag->name.'</a></li>';

                echo '<li><a href="#">View All</a><span class="arrow"></span>
                </li>'; ?></ul>
                <?php ?>





                share|improve this answer

























                  1












                  1








                  1







                  I tried this and worked for me.



                  <?php
                  $tags = get_tags();
                  if ($tags)
                  ?><ul class="tags"><?php
                  foreach ($tags as $tag)
                  echo '<li><a href="' . get_tag_link( $tag->term_id ) . '"
                  title="' . sprintf( __( "View all posts in %s" ), $tag-
                  >name ) . '" ' . '>' . $tag->name.'</a></li>';

                  echo '<li><a href="#">View All</a><span class="arrow"></span>
                  </li>'; ?></ul>
                  <?php ?>





                  share|improve this answer













                  I tried this and worked for me.



                  <?php
                  $tags = get_tags();
                  if ($tags)
                  ?><ul class="tags"><?php
                  foreach ($tags as $tag)
                  echo '<li><a href="' . get_tag_link( $tag->term_id ) . '"
                  title="' . sprintf( __( "View all posts in %s" ), $tag-
                  >name ) . '" ' . '>' . $tag->name.'</a></li>';

                  echo '<li><a href="#">View All</a><span class="arrow"></span>
                  </li>'; ?></ul>
                  <?php ?>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 27 '18 at 4:25









                  Rakhi PrajapatiRakhi Prajapati

                  3671514




                  3671514





















                      0














                      edit this code and work for me !!!



                      <ul class="tags">


                      <?php

                      $tags = get_tags('post_tag'); //taxonomy=post_tag
                      //echo "<pre>";
                      //print_r($tags);
                      //var_dump($tags);
                      if ( $tags ) :
                      foreach ( $tags as $tag ) : ?>
                      <li><a class="tag" href="<?php echo esc_url( get_tag_link( $tag->term_id ) ); ?>" title="<?php echo esc_attr( $tag->name ); ?>"><?php echo esc_html( $tag->name ); ?></a></li>
                      <?php endforeach; ?>
                      <?php endif; ?>
                      </ul>





                      share|improve this answer

























                      • Can you add some explanation to this code? To me, it looks like a scrambled copy of other answers

                        – Nico Haase
                        Nov 14 '18 at 9:41











                      • But this code show all tags. But i showing particular single post tag listing. can you use this code. <?php the_tags( '<ul class="tags"> <li class="tag">', '</li><li class="tag">', '</li></ul>' ); ?>

                        – Purnendu Sarkar
                        Nov 15 '18 at 7:13
















                      0














                      edit this code and work for me !!!



                      <ul class="tags">


                      <?php

                      $tags = get_tags('post_tag'); //taxonomy=post_tag
                      //echo "<pre>";
                      //print_r($tags);
                      //var_dump($tags);
                      if ( $tags ) :
                      foreach ( $tags as $tag ) : ?>
                      <li><a class="tag" href="<?php echo esc_url( get_tag_link( $tag->term_id ) ); ?>" title="<?php echo esc_attr( $tag->name ); ?>"><?php echo esc_html( $tag->name ); ?></a></li>
                      <?php endforeach; ?>
                      <?php endif; ?>
                      </ul>





                      share|improve this answer

























                      • Can you add some explanation to this code? To me, it looks like a scrambled copy of other answers

                        – Nico Haase
                        Nov 14 '18 at 9:41











                      • But this code show all tags. But i showing particular single post tag listing. can you use this code. <?php the_tags( '<ul class="tags"> <li class="tag">', '</li><li class="tag">', '</li></ul>' ); ?>

                        – Purnendu Sarkar
                        Nov 15 '18 at 7:13














                      0












                      0








                      0







                      edit this code and work for me !!!



                      <ul class="tags">


                      <?php

                      $tags = get_tags('post_tag'); //taxonomy=post_tag
                      //echo "<pre>";
                      //print_r($tags);
                      //var_dump($tags);
                      if ( $tags ) :
                      foreach ( $tags as $tag ) : ?>
                      <li><a class="tag" href="<?php echo esc_url( get_tag_link( $tag->term_id ) ); ?>" title="<?php echo esc_attr( $tag->name ); ?>"><?php echo esc_html( $tag->name ); ?></a></li>
                      <?php endforeach; ?>
                      <?php endif; ?>
                      </ul>





                      share|improve this answer















                      edit this code and work for me !!!



                      <ul class="tags">


                      <?php

                      $tags = get_tags('post_tag'); //taxonomy=post_tag
                      //echo "<pre>";
                      //print_r($tags);
                      //var_dump($tags);
                      if ( $tags ) :
                      foreach ( $tags as $tag ) : ?>
                      <li><a class="tag" href="<?php echo esc_url( get_tag_link( $tag->term_id ) ); ?>" title="<?php echo esc_attr( $tag->name ); ?>"><?php echo esc_html( $tag->name ); ?></a></li>
                      <?php endforeach; ?>
                      <?php endif; ?>
                      </ul>






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 14 '18 at 9:40









                      a_k_v

                      794112




                      794112










                      answered Nov 14 '18 at 8:09









                      Purnendu SarkarPurnendu Sarkar

                      12




                      12












                      • Can you add some explanation to this code? To me, it looks like a scrambled copy of other answers

                        – Nico Haase
                        Nov 14 '18 at 9:41











                      • But this code show all tags. But i showing particular single post tag listing. can you use this code. <?php the_tags( '<ul class="tags"> <li class="tag">', '</li><li class="tag">', '</li></ul>' ); ?>

                        – Purnendu Sarkar
                        Nov 15 '18 at 7:13


















                      • Can you add some explanation to this code? To me, it looks like a scrambled copy of other answers

                        – Nico Haase
                        Nov 14 '18 at 9:41











                      • But this code show all tags. But i showing particular single post tag listing. can you use this code. <?php the_tags( '<ul class="tags"> <li class="tag">', '</li><li class="tag">', '</li></ul>' ); ?>

                        – Purnendu Sarkar
                        Nov 15 '18 at 7:13

















                      Can you add some explanation to this code? To me, it looks like a scrambled copy of other answers

                      – Nico Haase
                      Nov 14 '18 at 9:41





                      Can you add some explanation to this code? To me, it looks like a scrambled copy of other answers

                      – Nico Haase
                      Nov 14 '18 at 9:41













                      But this code show all tags. But i showing particular single post tag listing. can you use this code. <?php the_tags( '<ul class="tags"> <li class="tag">', '</li><li class="tag">', '</li></ul>' ); ?>

                      – Purnendu Sarkar
                      Nov 15 '18 at 7:13






                      But this code show all tags. But i showing particular single post tag listing. can you use this code. <?php the_tags( '<ul class="tags"> <li class="tag">', '</li><li class="tag">', '</li></ul>' ); ?>

                      – Purnendu Sarkar
                      Nov 15 '18 at 7:13


















                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39685167%2flist-all-the-tags-in-a-wordpress-blog%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kleinkühnau

                      Makov (Slowakei)

                      Deutsches Schauspielhaus