Find a Record by POST ID
Hey everyone,
I have a simple pod that is associated via PICK column to a WordPress post.
I'm currently using the default WordPress Loop to iterate over my posts and ideally, I'd then like to be able to take the POSTID for a given post and use it as a filter parameter in my pods object.
I have my post id, but i'm having troubles figuring out what I need to do to only return the relavent pod based on the post id instead of getting all my pods and iterating over them until i find the one with the matching id.
There's got to be a better way! (haha cue, cheesy 90's infomercial)
Any one got some ideas?
M
1 Answer
Ohh I figured it out! :) Actually it was embarrassingly easy
Basically what I did was, I added a new join on the wp_pod_rel table which contains all the relationships for my various pods. Then I associated the relationship table ID w/ the ID for the wp_pod.
I then added a new where clause that would filter the entire list based upon the passed in $postID that I got from my WordPress Loop
Hope this helps someone!
$episode = new Pod('episode');
// Grab the appropriate pod episode based on the current post
$params = array();
$params['join'] = ' INNER JOIN wp_pod_rel AS relation ON relation.id = p.tbl_row_id';
$params['where'] = 'relation.tbl_row_id = ' . $postID;
$episode->findRecords($params, 1);
