WordPress.org

Ready to get started?Download WordPress

Forums

Help Needed with Menu based on tag and catagory Intesection (4 posts)

  1. rohantendolkar
    Member
    Posted 1 year ago #

    My website have categories on which i have modified so that i can put menu and images on header. i want to provide with menu (of tags) which will refine result for that category and tag. menu( based on tags) will not be used anywhere else
    references used before
    1. tdo tag fixes
    thank you

  2. bcworkz
    Member
    Posted 1 year ago #

    You can build a tag menu using wp_tag_cloud() or if you don't like the cloud thing, build a menu from the return from get_tags(). Of course this does not consider the current category. In order for your permalinks to accept both tag and category parameters, you would need to use the Rewrite API to set it up. However, if you use the traditional URL parameter form, you can build a combined tag and category_name link and it will work as expected, though the category archive is used, it is limited by the tag parameters as well.

    So you need to alter the tag link hrefs to look something like this:
    example.com/index.php?category_name=fruit&tag=apple

    You can get the current category from the global $wp_query object.

  3. rohantendolkar
    Member
    Posted 1 year ago #

    Please provide me with details what i exactly need to modify. I am new to api references. please provide me with more detailed reference

    Thank you

  4. bcworkz
    Member
    Posted 1 year ago #

    Something like this on your category template, outside the loop (untested):

    <?php $tags=get_tags();
    $cat=single_term_title(); //category name
    foreach($tags as $tag) {
       echo "<a href=\"example.com/index.php?category_name=$cat&tag=$tag->name\">$tag->name</a><br>";
    } ?>

    Of course the href needs to be altered for your site and WP location.

Topic Closed

This topic has been closed to new replies.

About this Topic