Find a Record by POST ID

0

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

asked Jan 28 at 12:30

reado

18

add comment
enter at least 15 characters

1 Answer

0

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);

answered Jan 28 at 2:24

reado

18

add comment
enter at least 15 characters