1

I build a Wordpress website with a page called 'Nieuwsberichten'. The url looks like

https://www.example.com/nieuwsberichten

This page is dynamic and I need an extra parameter called 'news_page'

https://www.example.com/nieuwsberichten/?news_page=recent

The URL above is not friendly so I create a rewrite rule for this and I add the variable 'news_page'.

functions.php

function add_query_vars($vars){   
    $vars[] = 'news_page';     
    return $vars;
}
add_filter( 'query_vars', 'add_query_vars', 10, 1 );

function rewrite_paged(){
    add_rewrite_rule('^nieuwsberichten/([0-9]+)/?', 'nieuwsberichten?news_page=$matches[1]', 'top');
}
add_action('init', 'rewrite_paged');

After this I flushed the permalinks menu -> settings -> permalinks -> save

If I browse to

https://www.example.com/nieuwsberichten/recent/

It will redirect to

https://www.example.com/nieuwsberichten/

What do I miss in my code?

Hope somebody can help me with this

0

Your Answer

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