WordPress.org

Support

Support » How-To and Troubleshooting » List of tags related to a specific categoy

List of tags related to a specific categoy

  • Hi!
    I’m writing the code of my own theme, in localhost.
    The blog is about music lyrics.
    The title of the entries, are the name of the song.
    The tag is the name of the artist.
    And the categories, are the first letter of the artist name.
    In the top, I have a horizontal bar with an alphabetical list of categories, and what I want, is that when I click in the “A”, show a list of the artist with its name starting with “A”.
    I have done this, with this code:

    <?php /* The loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<a href="<?php the_permalink() ?>"><?php the_tags( '<h4>', '</h4>' ); ?></a>
    			<?php endwhile; ?>

    It gives me a list of the tags (artist), but some are duplicated (because I have different songs of the same artist).
    What do I need to do to get a list of the tags, but without duplicating them?
    If I click on the “S”, i get a list like this:

    Status Quo
    Status Quo
    Status Quo
    Scorpions
    Scorpions
    Supertramp

    and what I want is:

    Status Quo
    Scorpions
    Supertramp

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • you can filter using array_unique() php function.. but you might need to fetch the tags as array using get_tags()..

    Thank you.

    I’ll try this. But if I find it too difficult, maybe I’ll change using a plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List of tags related to a specific categoy’ is closed to new replies.