Passing custom args in paginate_links

To add arguments to the links in paginate posts, use the 'add_args' argument in the function. You have to pass the arguments as an associative array. So, to add project=1 to the end of all your links, you would do this:

global $wp_query;
paginate_links(array(
  'total' => $wp_query->max_num_pages,
  'current' => (get_query_var('paged') ? get_query_var('paged') : 1),
  'base' => 'http://domain.com/about/%_%',
  'format' => 'page/%#%',
  'add_args' => array( 'project' => 1 /* or whatever the project number is*/ ),
));

Hope that helped!

EDIT

To get domain.com/about/projects/1/page/1, you can add a custom permastruct. I’m going to assume about is a page.

function wpse21802_init(){
  add_rewrite_rule( '([^/]+)/projects/([^/])/?$', 'index.php?pagename=$matches[1]&project=$matches[2]', 'top' );
  add_rewrite_rule( '([^/]+)/projects/([^/])/page/(/d+)/?$', 'index.php?pagename=$matches[1]&project=$matches[2]&paged=$matches[3]', 'top' );
}
add_action( 'init', 'wpse21802_init' );

After adding that code, flush the rewrite rules by going to Settings -> Permalinks.

Leave a Comment