I found a solution how to get the list of all tags

  • Unknown's avatar

    Hello!

    I am coming from Blogger and I am very new to everything WordPress. I successfully imported my blog to WordPress.com using a paid version of a plugin called “Blogger Importer Extended” made by pipdig. At first, right after import all posts were empty but somehow the contents appeared later so all good with that (so far).

    But to my surprise, WordPress.com does not have a simple widget or whatever to get the list of ALL tags. It has the tag cloud option and that can be configured so that the cloud looks like a regular simple list (as I wanted it) but it has the maximum limit of 100 tags. My blog contains authors of old songs and abbreviation of old hymnal books too which I wanted to have as tags and I already have more than 100 of those. In my case, I want all of them listed, not just the “popular” ones. I estimate that the total number of these won’t go over 250 or 300 in the future. In Blogger, getting the list of all tags was just a simple component to add to my blog but it turned out nearly impossible to get the same thing in WordPress.com.

    I finally found a solution to get such a list and I write it down here too so others who stumble upon this problem can use it.

    First, I found a PHP code that will generate such a list here. This is the code copied from that website:

    <h2>Tags</h2>
    <ul>
    <?php
    $tags = get_tags();
    if ( $tags ) :
    foreach ( $tags as $tag ) : ?>
    <li><a 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>

    Very good! But I can’t enter PHP as a block into my blog. When I tried adding this as HTML, it produced nothing reasonable.

    But there is an option to do that: one has to convert the PHP code to something called “shortcode” within WordPress.com and then use that. I could do that using another plugin called “Insert PHP Code Snippet” by xyzscripts.com. I had to install this free plugin and then go to the new subsection it created in my admin panel. I named the new “snippet” as “all-tags” and used an option “Shortcode (manual)” when creating it. So I had this new snippet available.

    And now, finally, when editing a block in the suitable location in my template, I added a sub-block called Shortcode and the real code that I entered was this:

    [xyz-ips snippet="all-tags"]

    And there you go: I really have a list of all tags now!

    I wonder why is this list of ALL tags such a bad idea for WordPress.com to just have this as an option for everybody. It isn’t so unnatural thing and there have been many requests for this over the years in this forum.

    In case anybody has a nicer, simpler, shorter solution, just add it here. The simpler the better.

  • Hi there!

    Thanks so much for taking the time to share your detailed workaround. I’m really glad you found a solution that works for you.

    I also wanted to let you know that there is actually a simpler, built-in way to display all your tags without needing custom code or extra plugins. You can use the Terms Query block. Once you add it, you can choose “Tags” as the taxonomy and then set the “Number of items to display” field to 0, which tells WordPress to show all of your tags.

    Here’s a helpful guide on using the Terms Query block that explains this in more detail:
    https://wordpress.com/support/wordpress-editor/blocks/terms-query-block/

    That way, you won’t have to maintain a custom snippet, and it’s fully managed through the block editor.

    Thanks again for sharing your experience and your creative solution. If you have any other questions as you explore WordPress.com, don’t hesitate to ask!

  • Unknown's avatar

    Thank you for this information. I will try this soon and I can write how it works then but currently there is a new very big problem that appeared out of nowhere and I have to deal with that first.

  • Hi @poolryhm Sure, please feel free to take your time testing the Terms Query Block to ensure it meets your needs and works as expected on your site.

    I’m also sorry to hear you’ve encountered a new issue. When you have a moment, could you let us know a bit more about it if it appears to be related to your WordPress.com site? We’ll be happy to take a closer look and help in any way we can.

  • Unknown's avatar

    I just tested the Terms Query. Yes, it works so that I do have the list of all tags and when I chose Name and count at the beginning (right after adding the block), I also got the number of usage of each tag which is good.

    When searching for this option in this forum and through search engine, I just didn’t see this option being mentioned anywhere and the text “Terms Query” didn’t give me any hint at all that it could be used in my case.

    For my other issue I will make a separate post.

  • Hello @poolryhm, I’m really glad to hear it’s working well for you now 😊

    I completely understand how the block may not have appeared in forum threads or search results, as those can vary quite a bit depending on the search terms used and the search engine itself.

    Out of curiosity, I did a quick Google search for display list of tags in WordPress using blocks and I can see the Terms Query Loop block showing up as a suggested solution, which is great to know for future reference.

    Since everything is working as expected, I’ll go ahead and close this topic for now. If any new questions come up, please feel free to start a new thread and we’ll be happy to help.

  • The topic ‘I found a solution how to get the list of all tags’ is closed to new replies.