Forums

Show unrelated categories on a post (4 posts)

  1. steven_j_clark
    Member
    Posted 1 year ago #

    Hi

    Any ideas I would go about listing all the top level categories on a single post even if the post hasn't been tagged to them?

    For example say I've got toplevel1, toplevel2 and toplevel3 and I only tag a post to toplevel1, is there a way of still listing links to

    toplevel1
    toplevel2
    toplevel3

    on the single.php.

    Thanks in advance for any help.

    Steve

  2. MichaelH
    moderator
    Posted 1 year ago #

    The template tag, wp_list_categories(), with a parameter of depth=1 should do that.

  3. steven_j_clark
    Member
    Posted 1 year ago #

    Thanks for the quick response.

    Although that was not quite what I was after. It does list all the top level categories but only the ones that have been tagged to the post. What I am looking for is a way to list all the top level tags in general, whether they have been assigned to the post or not.

    Thanks

  4. MichaelH
    moderator
    Posted 1 year ago #

    If you want all categories, even if no posts are assigned that category then you want the to add the depth=0 to your parameters when using that tag.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags