Advertisement
lonchbox

lasts posts and next loop

Mar 29th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 KB | None | 0 0
  1. <section id="recent-posts">
  2.                     <h2 class="recent-heading"><?php _e( 'Últimos Posts', 'lonchpress' ); ?></h2>
  3.                     <?php
  4.  
  5.                     // Get the page as an Object
  6.                     $recent_args = array(
  7.                         'posts_per_page' => 4,
  8.                         'post__not_in'  => get_option( 'sticky_posts' ),
  9.                         'public' => true,
  10.                         'ignore_sticky_posts' => 1,
  11.                         'post_type' => 'post'
  12.                     );
  13.  
  14.                     // Our new query for the Recent Posts section.
  15.                     $recent = new WP_Query( $recent_args );
  16.  
  17.                     // The first Recent post is displayed normally
  18.                     while ( $recent->have_posts() ) : $recent->the_post();
  19.  
  20.                         // Set $more to 0 in order to only get the first part of the post.
  21.                         global $more;
  22.                         $more = 0;
  23.  
  24.                         get_template_part( 'content', 'home', get_post_format() );
  25.  
  26.                     endwhile;
  27.                    
  28.                     echo '
  29.                     <ul class="other-recent-posts">';
  30.                    
  31.                     // Get the page as an Object
  32.                     $orecent_args = array(
  33.                         'posts_per_page' => 4,
  34.                         'offset' => 4,
  35.                         'post__not_in'  => get_option( 'sticky_posts' ),
  36.                         'public' => true,
  37.                         'ignore_sticky_posts' => 1,
  38.                         'post_type' => 'post'
  39.                     );
  40.                    
  41.                     // Our new query for the Recent Posts section.
  42.                     $orecent = new WP_Query( $orecent_args );
  43.                    
  44.  
  45.                     // For all other recent posts, just display the title and comment status.
  46.                     while ( $orecent->have_posts() ) : $orecent->the_post(); ?>
  47.  
  48.                         <li class="entry-title">
  49.                             <h4><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'lonchpress' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h4>
  50.                             <!--<span class="comments-link">
  51.                                 <?php comments_popup_link( '<span class="leave-reply">' . __( 'Deja un comentario', 'lonchpress' ) . '</span>', __( '1 comentario', 'lonchpress' ), __( '% Comentario', 'lonchpress' ) ); ?>
  52.                             </span>-->
  53.                         </li>
  54.                     <?php
  55.                     endwhile;
  56.                     Lonchpress_content_nav( 'nav-below' );
  57.                     // If we had some posts, close the <ol>
  58.                     if ( $recent->post_count > 0 )
  59.                         echo '</ul>';
  60.                     ?>
  61.                 </section><!-- .recent-posts -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement