• Resolved ssqm20

    (@ssqm20)


    Hi,

    I have a non-hierarchical taxonomy ‘Offices’ on my website, in which I can add names of offices, with their contact in description. Is there a way to display the Offices’ names with description ? Something like an Index.

    Any help is much appreciated.

    Thanks!

    P.S. I have zero knowledge about coding, and I’m very new to this whole thing. Thank you for understanding.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hi @ssqm20

    Are you referring to an archive of all posts that have any term from this “offices” taxonomy? Similar to how custom post types have an archive URL to see all posts in that post type?

    If yes, then WordPress doesn’t offer that out of box, because of complexities I believe with how that’d work, especially around one post could have many terms. They do offer TERM archives for all post that have just one of those terms. Closest workaround I ever thought up is documented at https://docs.pluginize.com/article/creating-an-all-term-taxonomy-archive/.

    The trick with it is that we also make use of an “all” term and EVERY post involved gets that “all” term. and you’d view them all at /offices/all in your example.

    At that point, with the taxonomy archive template files, you’d make use of the description for the taxonomy there. For that specific detail, I believe you’d want to make use of https://developer.www.ads-software.com/reference/functions/the_archive_description/ and it’ll be smart enough to know what’s displaying to display the correct value.

    Thread Starter ssqm20

    (@ssqm20)

    I think you’ve almost got it. But the pages you shared is regarding post types, and not post taxonomies. Apologies if I got it wrong, I’m just starting to learn.

    Also here what I actually would like to achieve. These offices have names of offices listed, so for example Office ABCD also has an image and some text in the description. I’m trying to get that description to display alongside the office name.

    I really appreciate you taking the time. Hopefully there’s some solution to this thing that I want to do.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    To be certain, we have at least one taxonomy “offices”. Then you have a term of “Office ABCD”, and then a second term “Office EFGH”, and so on.

    These TERMS have their name, slug, image, description, etc. This is what you’re wanting to display. You’re not worried about necessarily the archives for the posts involved, you’re just wanting a place to list out the terms, and perhaps have those linked out to their respective archives, but that’s a later task.

    Basically a spot to list out the terms and their term information, with perhaps the taxonomy’s description displayed as well.

    If I’m closer to on track with what you’re trying to achieve now, I’ll provide some better links for what code to try out and some ideas of how to implement. I don’t have anything ready made at the moment, and we don’t have settings for this type of thing in CPTUI.

    Thread Starter ssqm20

    (@ssqm20)

    Yes! You got it exactly right.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    The only answers I can come up with are going to be code based. For example, using https://developer.www.ads-software.com/reference/functions/get_terms/

    That docs page has a lot of examples, but you would be able to fetch say all terms from the taxonomy, and receive an array of term objects. You would then be able to iterate over them and output information for each term. For example each object would have roughly whats documented at https://developer.www.ads-software.com/reference/functions/get_terms/#comment-1839

    You would then be also able to use the term ID to get any associated term meta with get_term_meta() very much like you would with get_post_meta() and whatnot.

    It’s also possible there are other plugins out there that would provide some UI for something like this, but I don’t know of any offhand.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display taxonomy children’ is closed to new replies.