wordpress paging within shortcode

0

I am trying to perform a simple paging within a shortcode, I have tried in many ways without success, what can I be doing incorrectly?

add_shortcode('tela-anuncios-compras', 'tela_anuncios_compras');

function tela_anuncios_compras( $atts ) {
    $args = array(
        'posts_per_page' => 2,
        'paged' => $paged,
        'post_type' => 'product',
        'order' => 'ASC',
        'orderby' => 'title',
    );

    $query = new WP_Query($args);

    while ($query -> have_posts()): $query->the_post();
        global $product, $post;
        echo "dados do item";
    endwhile;

    echo '<div class="listings clearfix"><div class="nav-previous">' . get_next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts' ) ) . '</div><div class="nav-next">' . get_previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>' ) ) . '</div></div>';

    wp_reset_query();
}
    
asked by anonymous 12.11.2018 / 16:59

0 answers