If my theme's user wants to set a static page as home, i want to make all posts url as they're children of the chosen blog index page. By example, suppose permalink is similar to;


or even with dates, and the chosen post index is named Blog, i want the permalink to be:


I tried to use the rewrite api this way (accounting the url structure without pretty permalinks)

function rewrite_rules () {
    if (get_option('show_on_front') == 'page') {
        add_rewrite_rule('blog/([a-zA-Z0-9_-]*$)', 'index.php?p=$matches[1]', 'top');
add_action('init', 'pagination_rewrite_rules');

but this got no effect: visiting blog/example-post sticks on blog. How can i achieve this goal? Thank you.


I found out that visiting url appending page id instead of slug, like blog/page-id, it works. But i want to use slugs! Working on it but still waiting for a pro solution


Oh well, i just remembered i can have this result without even programming. And if the theme is not for me i can advice how to do in docs. It was simple: Settings/Permalink/Custom Structure. I hope i'll be helpful for someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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