alandbh
3/13/2016 - 4:06 AM

Loop posts com wp_query. Serve para outros tipos

Loop posts com wp_query. Serve para outros tipos

<?php 
// WP_Query arguments
$args = array (
    'post_type'              => 'post', //it can be other
    'posts_per_page'         => '3'
);


// The Query
$postagens = new WP_Query( $args );

// The Loop
if( $postagens->have_posts() ) :
    while( $postagens->have_posts() ) : $postagens->the_post();
?>

  <p>
    <a href="<?php the_permalink(); ?>"><?php the_title() ?></a><br>
    <small class="date"><?php the_time('j \d\e F \d\e Y') ?></small>
  </p>
  <hr>

<?php 
  endwhile; 
  endif; 
  // end of loop 
?>
<?php 
/*
  Query posts de blog com paginação e com primeiro post diferenciado
  Usado em Gamarra
  Alan
*/
  // WP_Query arguments
  $paged    = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  $args     = array(
    'post_type'         => 'post', 
    'posts_per_page'    => 2, 
    'post_status'       => 'publish', 
    'paged'             => $paged 
    );
    
    $wp_query = new WP_Query( $args );
    $count    = 0;

  // The Loop
    while ( $wp_query->have_posts() ) : $wp_query->the_post();

    if ($cont == 0) {
      include 'loop-news-big.php';
    } else {
      include 'loop-news-small.php';
    }

    $cont++;
    endwhile; 

?>