Advertisement
Guest User

Untitled

a guest
May 12th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <?php
  2. /**
  3. WIDGET 1 query args
  4. widget will be added to theme by include('mywidget.php') in functions.php file
  5. */
  6. $featured_posts = new WP_Query(array(
  7.     'posts_per_page' => 3,
  8.     'category_name' => 'featured',
  9. ));
  10. $count = 1;
  11. ?>
  12. <ul id="featured_posts" class="clearfix">
  13.     <?php
  14.     global $do_not_duplicate;
  15.     global $post;
  16.     while($featured_posts->have_posts()): $featured_posts->the_post(); $do_not_duplicate[] = $post->ID;
  17.         if($count == 1): ?>
  18.             <!-- first featured post markup -->
  19.         <?php else : ?>
  20.             <!-- next two featured posts markup -->
  21.         <?php endif; ?>
  22.     <?php $count++; endwhile; ?>           
  23.     <?php wp_reset_postdata(); wp_reset_query(); ?>
  24. </ul>
  25.  
  26. <?php
  27. /**
  28. WIDGET 2 query args
  29. widget will be added to theme by include('mywidget.php') in functions.php file
  30. */
  31.  
  32. $categoryblock_posts = new WP_Query(array(
  33.     'posts_per_page' => 5,
  34.     'cat' => $cat_id,
  35.     'category__not_in' => 9
  36. ));
  37. $count = 1;
  38. ?>     
  39. <ul class="blog-list clearfix">        
  40.     <?php
  41.     global $do_not_duplicate;
  42.     while($categoryblock_posts->have_posts()): $categoryblock_posts->the_post(); $do_not_duplicate[] = $post->ID;
  43.         if($count == 1): ?>
  44.             <!-- first featured post markup -->
  45.         <?php else : ?>
  46.             <!-- next two featured posts markup -->
  47.         <?php endif; ?>
  48.     <?php $count++; endwhile; ?>           
  49.     <?php wp_reset_postdata(); wp_reset_query(); ?>
  50. </ul>
  51.  
  52.  
  53. <?php
  54. /**
  55. main loop on index.php
  56. */
  57.  
  58. <?php if ( have_posts() ) : ?>
  59.            
  60.     <?php get_sidebar('contentwidgets'); ?>
  61.     <ul>
  62.         <?php
  63.         global $do_not_duplicate;
  64.         $count = 1;
  65.         while(have_posts()): the_post();
  66.             if($post->ID == $do_not_duplicate) continue;
  67.             if($count == 1) :
  68.                 echo '<li class="col8 first clearfix">';
  69.                     get_template_part('content');
  70.                 echo '</li>';
  71.                 echo '<li id="infobox" class="col4-5 clearfix">';
  72.                     get_template_part('content', 'infobox');
  73.                 echo '</li>';
  74.             else :
  75.                 echo '<li class="clearfix">';
  76.                     get_template_part('content');
  77.                 echo '</li>';
  78.             endif;
  79.         $count++; endwhile;
  80.         wp_reset_query(); wp_reset_postdata(); v?>
  81.     </ul>
  82.  
  83. <?php endif; ?>
  84.  
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement