WordPress.org

Ready to get started?Download WordPress

Forums

Pods - Custom Content Types and Fields
[resolved] Query and present data from a pod based on one field's value? (3 posts)

  1. SlazSlackrabbit
    Member
    Posted 4 months ago #

    I'm currently building a new WP site as a request from a friend who's making 'let's play' videos on YouTube. He wants a 'game database' that allows him to easely add & link new games by filling a form. And for that reason I've choosen Pods as the plugin of choice. However, it's the first time I'm using WP for anything outside of it's ordinary functions.

    So first I've created a Custom Content Type pod called 'game', and added all the fields I require.

    Next, I enabled Templates and created a new template that'll display all pod fields from 'game' in a desired page layout. Works nice!

    Now I only need to create pages listing the content created with the pod 'game' based on certain criteria. I have a Relationship Field called 'platforms' containing a multiple choice list of game systems, and would like to use this field's values for sorting.

    I basically need, for example, a page listing links to all 'game' posts that have their 'platforms' value set to 'PS3'. Listing them using titles and clickable image links out of their respective pod items. I've tried something like this:

    [pods name="game" limit="50" where="t.platforms = 'PS3'"]<a href="./game/{@slug}" alt="Geen link gevonden" title="{@title}"><img src="{@boxart}" alt="{@title}"></a>[/pods]

    But all it does is generate a mySQL error for the 'where' tag. Everything I tried to enter in the where box results in a mySQL error.

    I'm sorry if this all seemed vague, I'm not much of a troubleshooter. But what is the easiest method for querying data out of a Pod and presenting it on a page?

    Thanks in advance!

    https://wordpress.org/plugins/pods/

  2. Josh Pollock
    Member
    Plugin Author

    Posted 4 months ago #

    You are very close to what you need. The where clause in your shortcode is not correct through. If you look at the chart at the bottom of this page you will see that for a post type with a custom defined list it should be in the form "related_field_name.meta_value". In your case "games.meta_value" should work.

  3. SlazSlackrabbit
    Member
    Posted 4 months ago #

    Thank you Josh! I read through the doc you linked and was able to correct the where clause and create all the functional pages I wanted!

    Thanks a lot, this plugin will save my friend hours of manual editing!

    ~Niek

Reply

You must log in to post.

About this Plugin

About this Topic