'How Can I Do LIMIT 1, 2 In WP_Query
I am using Wp_Query method and I want to learn is there any parameter to limit my query. I try to use LIMIT 1,2 in WP_Query. Thanks for advance!
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'ID',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'featured',
'value' => 'evet',
'compare' => '='
)
)
);
// The Query
$the_query = new WP_Query( $args );
Solution 1:[1]
you can use posts_per_page and offset args for WP_Query()
like:-
$query = new WP_Query( array( 'posts_per_page' => 5, 'offset' => 3 ) );
for more :- http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
you are asking for LIMIT 1,2 (means offset,count(how many rows)) so
posts_per_page = count
offset = offset
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |