Support » Fixing WordPress » paginate_links() not working on custom loop.

  • Leo Blanchette


    I’ve created a script that allows certain post information to be fetched remotely via xml feed.

    Its at a special url, which includes wp-load.php to get everything working.

    As far as I know, this approach is fairly appropriate.

    We enter the loop as usual…

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts( 'posts_per_page=5&paged=' . $paged . '&post_type[]=image' );
    if ( have_posts() ):
        while ( have_posts() ):
    //loop combined into xml ouput
    //and then the links, which I am still experimenting with...
    global $wp_query;
    $big = 999999999; // need an unlikely integer
    print_r( paginate_links( array(
    	'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    	'current' => max( 1, get_query_var('paged') ),
    	'total' => $wp_query->max_num_pages,
    	'type' => 'array'
    ) ));

    …however the links and pagination don’t work together. That is, the loop doesn’t respond to the variables in the url

    Just need a little guidance,thanks.

  • The topic ‘paginate_links() not working on custom loop.’ is closed to new replies.