Created
July 23, 2013 08:49
-
-
Save LaminSanneh/6060912 to your computer and use it in GitHub Desktop.
Wordpress : Loop WpQuery
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 | |
$first_query = new WP_Query('cat=7&showposts=3'); | |
while($first_query->have_posts()) : $first_query->the_post(); | |
the_excerpt(); | |
endwhile; | |
//Add next and previous links after query | |
next_posts_link('« Older Entries'); | |
previous_posts_link('Newer Entries »'); | |
//reset the query so you can get origin query | |
wp_reset_postdata(); | |
?> | |
//Stuff to help with options | |
$custom_query = new WP_Query('cat=-7,-8,-9'); // exclude any categories | |
$custom_query = new WP_Query('posts_per_page=3'); // limit number of posts | |
$custom_query = new WP_Query('order=ASC'); // reverse the post order |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment