WordPress.org

Ready to get started?Download WordPress

Forums

List of tags related to a specific categoy (3 posts)

  1. skizoide
    Member
    Posted 7 months ago #

    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.

  2. shadez
    Member
    Posted 7 months ago #

    you can filter using array_unique() php function.. but you might need to fetch the tags as array using get_tags()..

  3. skizoide
    Member
    Posted 7 months ago #

    Thank you.

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

Reply

You must log in to post.

About this Topic