Where do I put the offset function?
<?php
$args = array(
'post_type' => 'post',
'category_name' => 'category',
'orderby' => 'date',
'order' => 'DESC',
'showposts' => 4);
$wp_query = new WP_Query($args);
if($wp_query->have_posts()) :
while($wp_query->have_posts()) :
$wp_query->the_post(); ?>
Where do I put the offset function?
<?php
$args = array(
'post_type' => 'post',
'category_name' => 'category',
'orderby' => 'date',
'order' => 'DESC',
'showposts' => 4);
$wp_query = new WP_Query($args);
if($wp_query->have_posts()) :
while($wp_query->have_posts()) :
$wp_query->the_post(); ?>
Share
Improve this question
asked Nov 21, 2019 at 4:28
nabukenabuke
231 silver badge3 bronze badges
1 Answer
Reset to default 2offset
is one of the arguments that you can pass to WP_Query
, so it belongs in the $args
array:
$args = array(
'post_type' => 'post',
'category_name' => 'category',
'orderby' => 'date',
'order' => 'DESC',
'showposts' => 4,
'offset' => 4,
);
PS: $wp_query
is a reserved variable used by the main query. When creating your own WP_Query
instance you should use a different variable name.