Support » Plugin: Pods - Custom Content Types and Fields » How to display a generated list of taxonomy items?

  • Resolved Funkphenomenon

    (@funkphenomenon)


    I’m building a website for a small brick and mortar store. I’m able to display a list of items belonging to a specific content type, but I don’t understand how to display a list of items belonging to a specific taxonomy.

    https://www.ostraining.com/class/pods/ explains how to create a list of books, a list of authors, but not a list of genres, or a list of book languages. How do I do that?

    Suppose I would like to end up with:

    • domain.tld/books/ [overview of books]
    • domain.tld/book/book-A/
    • domain.tld/book/book-B/
    • domain.tld/authors/ [overview of authors]
    • domain.tld/author/author-X/
    • domain.tld/author/author-Y/
    • domain.tld/genres/ [overview of genres]
    • domain.tld/genre/horror/
    • domain.tld/genre/scifi/
    • domain.tld/languages/ [overview of languages]
    • domain.tld/language/english/
    • domain.tld/language/german/

    I already created:

    • Book: content type
    • Author: content type
    • Genre: taxonomy
    • Language: taxonomy

    Book fields:

    • Relationship with author
    • Genre taxonomy: horror, scifi
    • Language taxonomy: English, German, French

    To create an overview of books, I created a regular WordPress page that contains the shortcode:
    [pods name="books" orderby="post_title ASC" template="list-of-books-template"]

    To create an overview of authors, I created a regular WordPress page that contains the shortcode:
    [pods name="authors" orderby="post_title ASC" template="list-of-authors-template"]

    Suppose I create a page domain.tld/genres/ . To create an overview of taxonomy items on a regular WordPress page, the same trick results in a database error ("Unknown column 'post_title' in 'order clause").

    If I use [each genre]<li>{@name}</li>[/each] on a regular WordPress page I end up with the code published on the page, not with a list.

    1. How do I end up with a page that shows an overview of the available genres?
    2. Is it also possible to have Pods auto-generate such pages? (E.g. if I go to domain.tld/genre/ that it just shows all the genres)
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @funkphenomenon

    Taxonomies are archive pages and they do not have archive pages of their own.
    However, you can use the shortcode as you would use on the books and authors pages.
    The difference is that a taxonomy object doesn’t contain a post_title. This is for posts only. Taxonomies have a name parameter.
    Example:
    [pods name="genres" orderby="name ASC" template="list-of-genres-template"]

    Cheers, Jory

    Thread Starter Funkphenomenon

    (@funkphenomenon)

    Thank you for your reply. So it looks like I can have Pods generate a list on any page, as long as I have a working shortcode.

    To use your example shortcode I think I would need to have:

    • Genre taxonomy, with genres: I created a taxonomy “Genre”, with items “horror” etc
    • list-of-genres-template: I created a pod template called list-of-genres-template that contains <li><a href="{@permalink}">{@name}</a></li>
    • Page to paste the code: I created domain.tld/genres/, that contains [pods name="genre" orderby="name ASC" template="list-of-genres-template"]

    Question 1a: This would be a correct way to do it, right?

    Still it gives me:
    SQL: SELECT DISTINCTt.* FROMdatabasetable_termsAStLEFT JOINdatabasetable_term_taxonomyASttONtt.term_id=t.term_idLEFT JOINdatabasetable_term_relationshipsAStrONtr.term_taxonomy_id=tt.term_taxonomy_idWHERE (tt.taxonomy= "genre" ) ORDER BY post_title ASC,t.name,t.term_idLIMIT 0, 15; Response: Unknown column 'post_title' in 'order clause'

    Question 1b: How do I make it work?

    Thread Starter Funkphenomenon

    (@funkphenomenon)

    After some more testing, I can confirm that I was able to publish a list of taxonomy items without errors by using the following steps:

    1. Create a taxonomy (e.g. Genre), with taxonomy items (e.g. horror)
    2. Create a Pods template for the list (e.g. template called list-of-genres-template) that contains <li><a href="{@permalink}">{@name}</a></li>
    3. In settings of the taxonomy, go to tab Autotemplate options and select the aforementioned template
    4. Manually create a page where you want to display the taxonomy list
    5. Add the shortcode, e.g. [pods name="genre" orderby="name ASC" template="list-of-genres-template"]
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to display a generated list of taxonomy items?’ is closed to new replies.