Paginate recent posts widget

Remove:

'no_found_rows' => true,

from your WP_Query call inside the widget code.

Additionally I would suggest to make this change :

'base' => add_query_arg( 'latest_page', '%#%' ),

in your paginate_links call, because add_query_arg() will handle if ? or & is used.

This should make the pagination work in your widget.

Note: I’m almost, haven’t tested it, certain that this won’t work on the front page if a static page is selected to show.


Update:

After I have taken a quick look at some code of mine I’m sure that the pagination won’t work on the front page if a static page is selected to show there. In this code I introduced a additional $_GET variable, which should not be registered as query variable, to work around it. Below a outlined approach how to use this:

  1. Setup the $latest_page variable differently

    if ( is_front_page() ) {
       $latest_page = ( isset( $_GET[ 'fplp' ] ) ) 
         ? $_GET[ 'fplp' ]
         : 1;
    } else {
       $latest_page = ( get_query_var( 'latest_page' ) ) 
         ? get_query_var( 'latest_page' ) 
         : 1;
    }
    
  2. Additionally setup the base and format parameter of paginate_links differently

    $base = ( is_front_page()
      ? add_query_arg( 'fplp', '%#%' )
      : add_query_arg( 'latest_page', '%#%' )
    );
    $format = ( is_front_page()
      ? '?fplp=%#%' 
      : '?latest_page=%#%' 
    );
    $args = array(
      'base' => $base,
      'format' => $format
       // some other parameter
    );
    paginate_links( $args );
    

With this you can the paginate the widget under above mentioned conditions.

Note: Of course adding the query variable could be dropped completely and one could solely work with a $_GET variable.