cwp_loop_callback

The CWP Responsive Magazine cwp loop callback function.

Description

cwp_loop_callback(); 

Usage

  1. if ( !function_exists( 'cwp_loop_callback' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = cwp_loop_callback(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function cwp_loop_callback() { 
  2. global $post; 
  3.  
  4. $args = array( 
  5. 'posts_per_page' => -1,  
  6. 'post__in' => get_option('sticky_posts') 
  7. ); 
  8. $my_query1 = new WP_Query($args); 
  9. while ($my_query1->have_posts()) : $my_query1->the_post(); 
  10. ?> 
  11. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
  12. <header class="entry-header"> 
  13.  
  14. <div class="entry-thumbnail">  
  15. <?php 
  16. if ( has_post_thumbnail() ) { 
  17. ?> 
  18. <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"> 
  19. <?php 
  20. the_post_thumbnail(array(350, 250), array('class' => 'alignleft')); 
  21. ?> 
  22. </a> 
  23. <?php 
  24. ?> 
  25. </div> 
  26.  
  27. <div class="entry-meta meta-top"> 
  28. <div class="post-categories"> 
  29. <?php the_category(' / '); ?> 
  30. </div> 
  31. <?php if ( 'post' == get_post_type() ) : ?> 
  32. <div class="entry-meta"> 
  33. <?php cwp_megar_posted_on(); ?> 
  34. </div><!-- .entry-meta --> 
  35. <?php endif; ?>  
  36. </div> 
  37. <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2> 
  38. </header><!-- .entry-header --> 
  39.  
  40. <?php if ( is_search() ) : // Only display Excerpts for Search ?> 
  41. <div class="entry-summary"> 
  42. <?php the_excerpt(); ?> 
  43. </div><!-- .entry-summary --> 
  44. <?php else : ?> 
  45. <div class="entry-content"> 
  46. <?php the_excerpt(); ?> 
  47. <?php //the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'cwp-megar' ) ); ?> 
  48. <?php 
  49. wp_link_pages( array( 
  50. 'before' => '<div class="page-links">' . __( 'Pages:', 'cwp-megar' ),  
  51. 'after' => '</div>',  
  52. ) ); 
  53. ?> 
  54. </div><!-- .entry-content --> 
  55. <?php endif; ?> 
  56.  
  57. </article><!-- #post-## --> 
  58.  
  59. <?php 
  60. endwhile; 
  61. wp_reset_postdata(); 
  62.  
  63. $numPosts = (isset($_GET['numPosts'])) ? $_GET['numPosts'] : 0; 
  64. $page = (isset($_GET['pageNumber'])) ? $_GET['pageNumber'] : 0; 
  65. $catt = (isset($_GET['catNumber'])) ? $_GET['catNumber'] : -1; 
  66. $yearr = (isset($_GET['yearPar'])) ? $_GET['yearPar'] : -1; 
  67. $monthh = (isset($_GET['monthPar'])) ? $_GET['monthPar'] : -1; 
  68. $authorr = (isset($_GET['authorPar'])) ? $_GET['authorPar'] : -1; 
  69. $tagg = (isset($_GET['tagPar'])) ? $_GET['tagPar'] : -1; 
  70.  
  71.  
  72. if($catt != -1): 
  73.  
  74. query_posts(array( 
  75. 'posts_per_page' => $numPosts,  
  76. 'paged' => $page,  
  77. 'cat' => $catt,  
  78. 'post_status' => 'publish',  
  79. 'post__not_in' => get_option( 'sticky_posts' ) 
  80. )); 
  81. elseif($yearr != -1 && $monthh != -1): 
  82.  
  83. query_posts(array( 
  84. 'posts_per_page' => $numPosts,  
  85. 'paged' => $page,  
  86. 'year' => $yearr,  
  87. 'monthnum' => $monthh,  
  88. 'post_status' => 'publish',  
  89. 'post__not_in' => get_option( 'sticky_posts' ) 
  90. )); 
  91.  
  92. elseif($yearr != -1): 
  93.  
  94. query_posts(array( 
  95. 'posts_per_page' => $numPosts,  
  96. 'paged' => $page,  
  97. 'year' => $yearr,  
  98. 'post_status' => 'publish',  
  99. 'post__not_in' => get_option( 'sticky_posts' ) 
  100. )); 
  101.  
  102. elseif($authorr != -1): 
  103.  
  104. query_posts(array( 
  105. 'posts_per_page' => $numPosts,  
  106. 'paged' => $page,  
  107. 'author_name' => $authorr,  
  108. 'post_status' => 'publish',  
  109. 'post__not_in' => get_option( 'sticky_posts' ) 
  110. )); 
  111.  
  112. elseif($tagg != -1): 
  113.  
  114. query_posts(array( 
  115. 'posts_per_page' => $numPosts,  
  116. 'paged' => $page,  
  117. 'tag' => $tagg,  
  118. 'post_status' => 'publish',  
  119. 'post__not_in' => get_option( 'sticky_posts' ) 
  120. )); 
  121.  
  122. else: 
  123.  
  124. query_posts(array( 
  125. 'posts_per_page' => $numPosts,  
  126. 'paged' => $page,  
  127. 'post_status' => 'publish',  
  128. 'post__not_in' => get_option( 'sticky_posts' ) 
  129. )); 
  130. endif; 
  131.  
  132. $cpage = $page;  
  133.  
  134. while ( have_posts() ) : the_post(); ?> 
  135.  
  136.  
  137.  
  138.  
  139. <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
  140. <header class="entry-header"> 
  141.  
  142. <div class="entry-thumbnail">  
  143. <?php 
  144. if ( has_post_thumbnail() ) { 
  145. ?> 
  146. <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"> 
  147. <?php 
  148. the_post_thumbnail(array(250, 250), array('class' => 'alignleft')); 
  149. ?> 
  150. </a> 
  151. <?php 
  152. ?> 
  153. </div> 
  154.  
  155. <div class="entry-meta meta-top"> 
  156. <div class="post-categories"> 
  157. <?php the_category(' / '); ?> 
  158. </div> 
  159. <?php if ( 'post' == get_post_type() ) : ?> 
  160. <div class="entry-meta"> 
  161. <?php cwp_megar_posted_on(); ?> 
  162. </div><!-- .entry-meta --> 
  163. <?php endif; ?>  
  164. </div> 
  165. <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2> 
  166. </header><!-- .entry-header --> 
  167.  
  168. <?php if ( is_search() ) : // Only display Excerpts for Search ?> 
  169. <div class="entry-summary"> 
  170. <?php the_excerpt(); ?> 
  171. </div><!-- .entry-summary --> 
  172. <?php else : ?> 
  173. <div class="entry-content"> 
  174. <?php the_excerpt(); ?> 
  175. <?php //the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'cwp-megar' ) ); ?> 
  176. <?php 
  177. wp_link_pages( array( 
  178. 'before' => '<div class="page-links">' . __( 'Pages:', 'cwp-megar' ),  
  179. 'after' => '</div>',  
  180. ) ); 
  181. ?> 
  182. </div><!-- .entry-content --> 
  183. <?php endif; ?> 
  184.  
  185. </article><!-- #post-## --> 
  186.  
  187.  
  188. <?php endwhile; 
  189. $all = wp_count_posts(); 
  190. $pall = ceil($all->publish/$numPosts); 
  191. if($cpage<$pall) { 
  192. ?> 
  193.  
  194.  
  195. <?php }  
  196.  
  197.  
  198. die(); // this is required to return a proper result