-
-
Save JacobLett/dc3f1d1a313f9bdba0f9 to your computer and use it in GitHub Desktop.
Pods find (query) based on field value - Used on Genesis home page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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