I have a custom post type called news and in order to distinguish current and old news posts I have a custom field where the client can mark a news post as 'archived'.

So my permalink rewrite code looks like this:

function custom_rewrite_rule() {
add_action('init', 'custom_rewrite_rule', 10, 0);

function add_query_vars_filter( $vars ){
    $vars[] = "news_archive";
    return $vars;
add_filter( 'query_vars', 'add_query_vars_filter' );

The first bit works but the problem is with the pagination. I can access the news_archive query_var but not the paged query_var.

What is the correct way to incorporate paged into this permalink rewrite?

1 Answer 1


The problem is that your first rule is capturing anything that begins with news/archive/.

Add the $ anchor to match only news/archive/:


Your pagination rule will then begin to work as-is after you flush permalinks.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.