Advertisement
Guest User

end this loop properly

a guest
Sep 12th, 2011
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.06 KB | None | 0 0
  1.     <?php
  2.     //for in the loop, display all "content", regardless of post_type,
  3.     //that have the same custom taxonomy (e.g. genre) terms as the current post (pick cat)
  4.     $backup = $post;  // backup the current object
  5.     $found_none = '';
  6.     $taxonomy = 'kund';//  e.g. post_tag, category, custom taxonomy
  7.     $param_type = 'kund'; //  e.g. tag__in, category__in, but genre__in will NOT work
  8.     $post_types = get_post_types( array('public' => true), 'names' );
  9.     $tax_args=array('orderby' => 'none');
  10.     $tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args);
  11.     if ($tags) {
  12.       foreach ($tags as $tag) {
  13.         $args=array(
  14.           "$param_type" => $tag->slug,
  15.           'post__not_in' => array($post->ID),
  16.           'post_type' => $post_types,
  17.           'showposts'=>-1,
  18.           'cat' => 5,
  19.           'caller_get_posts'=>1
  20.     );
  21.     $my_query = null;
  22.     $my_query = new WP_Query($args);
  23.   if( $my_query->have_posts() ) { ?>
  24.         <div id="wrapper-extra" class="container_24">
  25.         <div class="thumbnails">
  26.             <div class="grid_24"><h3 class="liten-rubrik"></h3></div>
  27.         <?php  while ($my_query->have_posts()) :?>
  28.         <?php $my_query->the_post(); ?>
  29.         <div class="newsbox grid_8">
  30.             <div class="news-thumbnail">
  31.             <a class="news-thumbnail" href="<?php the_permalink() ?>" rel="<?php the_ID(); ?>" title="Nyhet - <?php the_title_attribute(); ?>">
  32.             <?php the_post_thumbnail(); ?></a>
  33.             </div>
  34.  
  35.            
  36.             <div class="news-description">
  37.             <a class="news-link" href="<?php the_permalink() ?>" rel="<?php the_ID(); ?>" title="Nyhet - <?php the_title_attribute(); ?>">
  38.             <?php the_title('<p class="news-titel">', '</p>'); ?>
  39.             <div class="news-excerpt"><?php the_excerpt(); ?></div>
  40.             <p class="news-date"><?php the_time('F j, Y'); ?></p>  
  41.             </a>
  42.             </div>
  43.            
  44.             <div class="mobile-title"><?php the_title('<p class="mobile-news-titel">', '</p>'); ?></div>
  45.         </div> <!-- end newsbox grid_8 --> 
  46.         <?php $found_none = '';
  47.         endwhile;
  48.         }
  49.       }
  50.     }
  51.     if ($found_none) {
  52.     echo $found_none;
  53.     }
  54.     $post = $backup;  // copy it back
  55.     wp_reset_query(); // to use the original query again
  56.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement