Last active
August 1, 2016 20:27
-
-
Save alandbh/fb3130d6afe316c331c2 to your computer and use it in GitHub Desktop.
Loop posts com wp_query. Serve para outros tipos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment