Skip to content

Instantly share code, notes, and snippets.

@arelthia
Last active November 23, 2019 20:57
Show Gist options
  • Save arelthia/0439e46ec2e096110753 to your computer and use it in GitHub Desktop.
Save arelthia/0439e46ec2e096110753 to your computer and use it in GitHub Desktop.
Pods find (query) based on field value - Used on Genesis home page
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'tht_featured_home', 5 );
function tht_featured_home() {
$where = "book_featured.meta_value='1'";
$params = array(
'where'=> $where,
'order' => 'ASC',
'limit' => 1,
'orderby' => 'title'
);
$book = new Pod('book');
$book->findRecords($params);
if($book->total()>0){
while($book->fetch()){
$cover_caption = $book->field('book_cover_caption');
$book_description = $book->field('book_description');
//Get the image url
$book_background = pods_image_url(get_post_meta( $book->id(), 'book_background_image', true ), 'large' );
//Get Related Field
$about_author = $book->field('book_author');
//Get related field image
$author_image = pods_image_url(get_post_meta( $about_author['ID'], 'author_picture', true ), 'large' );
/*Display stuff here */
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment