Advertisement
Guest User

multiple loop pagination

a guest
Feb 4th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.80 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. *
  5. * Display the Tip of the Day Custom Post Type archive custom fields using
  6. * ACF.
  7. *
  8. * @author Angie Meeker
  9. * @uses Advanced Custom Fields
  10. */
  11.  
  12. add_action('genesis_entry_content','genesis_do_post_title', 2);
  13.  
  14.  
  15.  
  16.  
  17.  
  18. //* Add Tip of the Day body class to the head
  19. add_filter( 'body_class', 'add_tiparchives_body_class' );
  20. function add_tiparchives_body_class( $classes ) {
  21. $classes[] = 'tiparchives-post-type-archive-{tipoftheday}';
  22. return $classes;
  23. }
  24.  
  25. // Return Category and Tip of the Day on Single Posts
  26. add_action ( 'genesis_before_content', 'show_totd', 9 );
  27. function show_totd() {
  28. echo '<div class="totd-cats-title">Tip of the Day</div>';
  29. }
  30. // Remove Post Author
  31. add_filter( 'genesis_post_info', 'remove_post_author_totd_posts' );
  32. function remove_post_author_totd_posts($post_info) {
  33. $post_info = '[post_date]';
  34. return $post_info;
  35. }
  36.  
  37.  
  38. /** Replace the standard loop with our custom loop */
  39. remove_action( 'genesis_loop', 'genesis_do_loop' );
  40. add_action( 'genesis_loop', 'totd_do_loop');
  41. add_action( 'genesis_loop', 'totd_teasers_do_loop');
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. add_action('genesis_loop', 'totd_do_loop');
  49. function totd_do_loop() {
  50. if ( !is_paged() ) {
  51. global $wp_query;
  52. // Set up your query here
  53. $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
  54. $query = array(
  55. 'post_type' => 'tipoftheday',
  56. 'orderby' => 'date',
  57. 'posts_per_page' => '1',
  58.  
  59. );
  60.  
  61. $wp_query = new WP_Query( $query );
  62.  
  63. if( $wp_query->have_posts() ):
  64. while( $wp_query->have_posts() ): $wp_query->the_post();
  65. // Get the custom fields
  66. // Store the pre tips data
  67. $tips_data_pre = array(
  68. 'totd_tags' => get_field( 'totd_tags' ),
  69. 'tip_article_headline' => get_field( 'tip_article_headline' ),
  70. 'article_author' => get_field( 'article_author' ),
  71. 'article_author_link' => get_field( 'article_author_link' ),
  72. );
  73.  
  74.  
  75. // Only output if we have tips data
  76. if ($tips_data_pre['totd_tags'] != '' ||
  77. $tips_data_pre['tip_article_headline'] != '' ||
  78. $tips_data_pre['article_author'] != '' ||
  79. $tips_data_pre['article_author_link'] != '') {
  80. echo '<span class="date time published" title="%1$s">' , do_shortcode('[post_date]'),'</span>' ;
  81.  
  82. echo '<div class="tip-excerpt"><p><div class="entry-content">';
  83. echo '<div class=h1 entry-title"><a href="'.get_permalink().'"title="'.get_the_title().'">' . get_the_title() . '</a></div>';
  84. echo the_excerpt();
  85. echo '<div class="entry-terms">' , do_shortcode('[post_terms taxonomy="totd_tags" before="See More Tips For: " taxonomy="totd_tags"] '),'</div>' ;
  86. echo '<div class="entry-terms">
  87. <div class="share">Share This Tip:</div>
  88. <div class="addthis_toolbox addthis_default_style">
  89. <a class="addthis_button_preferred_1"></a>
  90. <a class="addthis_button_preferred_2"></a>
  91. <a class="addthis_button_preferred_3"></a>
  92. <a class="addthis_button_preferred_4"></a>
  93. <a class="addthis_button_compact"></a>
  94. <a class="addthis_counter addthis_bubble_style"></a>
  95. </div>
  96. <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=manta"></script>
  97. </div>
  98. </div></div>';
  99.  
  100.  
  101. echo '</p>';
  102. }
  103.  
  104.  
  105.  
  106. endwhile;
  107.  
  108. endif;
  109. // Reset the query
  110. wp_reset_query();
  111. }
  112. }
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121. add_action('genesis_loop', 'totd_teasers_do_loop');
  122. function totd_teasers_do_loop() {
  123. global $wp_query;
  124. // Set up your query here
  125. $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 0;
  126. $query = array(
  127. 'post_type' => 'tipoftheday',
  128. 'orderby' => 'date',
  129. 'posts_per_page' => '10',
  130. 'offset' => '1',
  131. 'paged' => $paged,
  132. );
  133.  
  134. $wp_query = new WP_Query( $query );
  135.  
  136. if( $wp_query->have_posts() ):
  137. while( $wp_query->have_posts() ): $wp_query->the_post();
  138. // Get the custom fields
  139. // Store the pre tips data
  140. $tips_data_pre = array(
  141. 'totd_tags' => get_field( 'totd_tags' ),
  142. 'tip_article_headline' => get_field( 'tip_article_headline' ),
  143. 'article_author' => get_field( 'article_author' ),
  144. 'article_author_link' => get_field( 'article_author_link' ),
  145. );
  146.  
  147.  
  148. // Only output if we have tips data
  149. if ($tips_data_pre['totd_tags'] != '' ||
  150. $tips_data_pre['tip_article_headline'] != '' ||
  151. $tips_data_pre['article_author'] != '' ||
  152. $tips_data_pre['article_author_link'] != '') {
  153. echo '<div class="time-teaser">
  154. <span class="day">',get_the_time( 'l' ),'</span>
  155. <span class="month">',get_the_time( 'm/d/Y' ),'</span> </div>';
  156.  
  157. echo '<div class="tip-excerpt"><p><div class="entry-content">';
  158. echo '<div class=h2 entry-title"><a href="'.get_permalink().'"title="'.get_the_title().'">' . get_the_title() . '</a></div>';
  159. $excerpt = get_the_excerpt();
  160. echo string_limit_words($excerpt,25); echo '<a class="moretag" href="'. get_permalink($post->ID) . '"> Continue Reading&rarr;</a>';
  161. echo '<div class="entry-terms">' , do_shortcode('[post_terms taxonomy="totd_tags" before="See More Tips For: " taxonomy="totd_tags"] '),'</div>' ;
  162. echo '<div class="entry-terms"></div>
  163. </div></div>';
  164.  
  165.  
  166. echo '</p>';
  167. }
  168.  
  169.  
  170. endwhile;
  171. // Pagination! Woo!
  172. genesis_posts_nav();
  173. endif;
  174. // Reset the query
  175. wp_reset_query();
  176. }
  177.  
  178.  
  179. genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement