Support » Developing with WordPress » Pagination for WordPress default gallery

  • Here is the part of code handling pagination in functions.php:

    // Pagination Setup
    $current = (get_query_var('paged')) ? get_query_var( 'paged' ) : 1;
    $per_page = 3;
    $offset = ($current-1) * $per_page;
    $big = 999999999;
    $total = sizeof($attachments);
    $total_pages = round($total/$per_page);
    if( $total_pages < ( $total/$per_page ) ){
    	$total_pages = $total_pages+1;
    }
    // Pagination output
    $output .= paginate_links( array(
    	'base' => str_replace($big,'%#%',esc_url(get_pagenum_link($big))),
    	'format' => '?paged=%#%',
    	'current' => $current,
    	'total' => $total_pages,
    	'prev_text'    => __('&laquo;'),
    	'next_text'    => __('&raquo;')
    ) );

    The issue:

    The code successfully divides images into groups by three, successfully creates pages for these groups, successfully creates pagination numbers and successfully creates links to the pages. But when I click on any pagination link, I do not go anywhere.

    Although when the page ( [ redundant link removed ] ) has “Status: Draft”, pagination links does work as they are supposed to.

    Any ideas?

    • This topic was modified 2 weeks, 3 days ago by bonmot.
    • This topic was modified 2 weeks, 3 days ago by bonmot.
    • This topic was modified 2 weeks, 3 days ago by bonmot.
    • This topic was modified 2 weeks, 2 days ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.