[How to]
-
How to show a list of the book of the same author of the book that the user are see?
if('book-review' == get_post_type()) { $terms_ = get_the_terms( get_the_ID(), 'book-author' ); if(is_array($terms_)) { foreach ($terms_ as $category_) : ?> <div class="book-review-list"> <h3><a href="<?php echo get_term_link($category_->slug,'book-author');?>" title="<?php echo $category_->name; ?>">Book of the Author</a></h3> <ul> <?php $posts_ = get_posts(array('numberposts'=>30,'post_type' => 'book-review', 'tax_query' => array(array('taxonomy' => 'book-author','terms' => $category_->slug,'field' => 'slug')))); $temp = $post; foreach($posts_ as $post) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?><br><?php the_title(); ?></a></li> <?php endforeach; ?> <?php endforeach; ?> </ul> </div> <? } }
Insert this code in the single.php of your template
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘[How to]’ is closed to new replies.