WordPress.org

Ready to get started?Download WordPress

Forums

paginate_links() not working on custom loop. (1 post)

  1. Leo Blanchette
    Member
    Posted 1 year ago #

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

    Its at a special url http://www.website.com/special_xml.php, 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() ):
            the_post();
    
    //loop combined into xml ouput
    
        endwhile;
    else:
    endif;
    
    //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 http://www.website.com/special_xml.php/page/3/?page=3.

    Just need a little guidance,thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic