WordPress.org

Forums

Select certain tags to display instead of all tags. (4 posts)

  1. joshuahornby
    Member
    Posted 1 year ago #

    I am displaying all the tags by using this function

    <?php
    $tags = get_tags();
    $html = '<div class="post_tags">';
    foreach ( $tags as $tag ) {
    $tag_link = get_tag_link( $tag->term_id );
    
    $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
    $html .= "{$tag->name}</a>";
    }
    $html .= '</div>';
    echo $html;
    ?>

    This then prints out all the tags.

    Instead of display all tags is there a way I can say which tags I wish for it to display the slug and link to? So for example I can only display a tag called 'hello'

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    It may be easier to create a custom menu of just the tags you want and then add that menu using the menu widget in your theme widget location desired.

    http://codex.wordpress.org/Appearance_Menus_Screen The tags will be easy to add - make sure to check the Screen Settings.

  3. joshuahornby
    Member
    Posted 1 year ago #

    Brilliant! Thank you very much. Is there a way to know what has been clicked and then display this name on the page?

    For example you click on 'Cheese' and the new page says 'You have clicked Cheese'

  4. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    That is a theme item - ask theme dev.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags