Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- other posts -->
- <?php
- //get the post's terms (troubleshooting - can be removed once figured out!
- $category_terms = wp_get_object_terms($post->ID, 'category');
- if(!empty($category_terms)){
- if(!is_wp_error( $category_terms )){
- echo 'Terms <ul>';
- foreach($category_terms as $term){
- echo '<li><a href="'.get_term_link($term->slug, 'category').'">'.$term->name.'</a></li>';
- }
- echo '</ul>';
- }
- } //get post terms done
- ?>
- <?php
- //for a given post type, return all
- $category_terms = wp_get_object_terms($post->ID, 'category');
- $post_type = 'program_listings';
- $tax = 'category';
- $tax_terms = wp_get_object_terms($post->ID, 'category');
- if ($tax_terms) {
- foreach ($tax_terms as $tax_term) {
- $args=array(
- 'post_type' => $post_type,
- "$tax" => $tax_term->slug,
- 'post_status' => 'publish',
- 'operator' => 'AND',
- 'posts_per_page' => 5,
- 'caller_get_posts'=> 1
- );
- $my_query = null;
- $my_query = new WP_Query($args);
- if( $my_query->have_posts() ) {
- echo '<h2>Other programs in the '. $tax_term->name. ' category</h2> ';
- while ($my_query->have_posts()) : $my_query->the_post(); ?>
- <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
- <?php
- endwhile;
- }
- wp_reset_query();
- }
- }
- ?>
- <!-- end other posts -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement