Advertisement
Guest User

The WP loop

a guest
Apr 1st, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php
  2.     $limit = $atts['limit'] ? $atts['limit'] : 0;
  3.     $imgWidth = $atts['imgwidth'] ? $atts['imgwidth'] : "80";
  4.     $showImg = $atts['showimage'] == 'false' ? false : true;
  5.     $columns = isset($atts['columns']) ? $atts['columns'] : '4';
  6.     $args = array(
  7.         'cat' => $atts['category'],
  8.         'category_name' => $atts['slug'],
  9.         'tag' => $atts['tags'],
  10.         'post_type' => 'post',
  11.         'posts_per_page' => (isset($atts['limit']) ? $atts['limit'] : 6),
  12.         'order' => $atts['order'],
  13.         'orderby' => $atts['orderby']
  14.     );
  15.     $wp_q = new WP_Query($args);
  16.     $ResponsiveCounter = 1;
  17.     while($wp_q->have_posts())
  18.     {
  19.         $wp_q->the_post();
  20.         $post_class = '';
  21.         if($ResponsiveCounter == 1)
  22.             $post_class .= ' left-fit';
  23.         if($columns == '4')
  24.             $post_class .= ' grid col-220';
  25.         else if($columns == '3')
  26.             $post_class .= ' grid col-300';
  27.         else if($columns == '2')
  28.             $post_class .= ' grid col-460';
  29.         if(($columns == '2' && $ResponsiveCounter == 2) || ($columns == '3' && $ResponsiveCounter == 3) || ($columns == '4' && $ResponsiveCounter == 4)){
  30.             $post_class .= ' fit';
  31.             $ResponsiveCounter = 0;
  32.         }
  33.         echo '<div class="'.$post_class.'">';
  34.         $id = $wp_q->post->ID;
  35.         $myimage_html = '';
  36.         if($atts['hidetext'] == 'true')
  37.             echo '<li><a href="'.get_permalink($wp_q->post->ID).'">'.$wp_q->post->post_title.'</a></li>';
  38.         else
  39.             echo '<div id="nw_post_'.$id.'" class="plnaslov"><a href="'.get_permalink($wp_q->post->ID).'"><h4>'.$wp_q->post->post_title.'</h4></a></div>';
  40.         if($showImg)
  41.             $myimage_html = my_get_first_image($id);
  42.        
  43.         echo '<div class="plcontent">';
  44.         if($myimage_html != '')
  45.             $myimage_html .= '<br>';
  46.         echo $myimage_html.get_the_excerpt();
  47.         echo '</div>';
  48.         echo '</div>';
  49.         $ResponsiveCounter++;
  50.     }
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement