Domanda

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(); ?>
È stato utile?

Soluzione

offset 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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top