Pagination using paginate_links

This is a problem with the paginate_links function and having your default permalink structure set to postname/custom but wanting the pagination to use default link structure.

If you look at the code – https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/general-template.php#L0

You can see the following at the top of the paginate_links function

// Setting up default values based on the current URL.
$pagenum_link = html_entity_decode( get_pagenum_link() );
$url_parts    = explode( '?', $pagenum_link );

Then lower you will find the following:

// Merge additional query vars found in the original URL into 'add_args' array.
if ( isset( $url_parts[1] ) ) {
    Bunch of code here to set the format...
}

So the problem is when you use the postname permalink structure the $url_parts variable will only return 1 array value and the custom format checks only run if there are 2 return values in the array. And the code inside this if statement is what parses the format argument.

Therefore your format argument is completely ignored 🙁

If you go to Settings > Permalinks and you set your structure to “Plain” you should see the pagination links working as you would like.

You could try filtering the ‘get_pagenum_link’ function to return a “plain” link since the main issue is that this function ignores the format defined in paginate_links and instead uses the $wp_rewrite->using_permalinks() check – https://developer.wordpress.org/reference/functions/get_pagenum_link/