Rewrite URL not working in WordPress

I have a WordPress site in a subfolder like this: www.example.com/TEST. I want to rewrite a URL for a specific page which is from post_type = page.

For example, I have a page like this: www.example.com/TEST/albama-test

Read More

And I need end result URL to be like: www.example.com/TEST/albama-test/blog

How do I achieve this?

I tried to use add_rewrite_rule but it’s not working for me.

function custom_rewrite_basic() {
    add_rewrite_rule('^blog/([0-9]+)/?', 'index.php?page_id=1053', 'top');
}
add_action('init', 'custom_rewrite_basic');

Related posts

1 comment

  1. Try this code

    function custom_rewrite_basic() {
            add_rewrite_rule('albama-test/blog/?(/([^/]+))?/?','index.php?pagename=albama-test','top');
    }
    add_action('init', 'custom_rewrite_basic');
    

Comments are closed.