First I check if meta checkbox is selected, indicating that the ‘book’ has chapters linked to it.
If it is, I run a loop to output all ‘chapter’ custom posts that have meta box value equal to current ‘book’ post slug value. That is the way I am linking the ‘chapter’ to ‘book’ – by inputting book’s slug into chapter’s meta box.
So listing chapters within a book is simple and works fine. However, I would also like to display book’s meta values from within ‘chapter’ post and that’s where I’m stumped.
I cannot figure out a way to get to ‘book’ custom post data by using values that are stored on the ‘chapter’ side. I want to be able to point the ‘book’ post by providing some meta value in ‘chapter’ post.
OK, I figured it out – bad case of brain fart I guess. It was as simple as creating a query to display ‘book’ custom post based on the meta key value from the ‘chapter’:
$parent_name = get_post_meta($post->ID, 'ecpt_chapter_parent', true); //getting the 'book' post name value from current 'chapter' post
$temp = $chapter_query;
$chapter_query = new WP_Query();
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
*May or may not contain any actual "CSS" or "Tricks".