Blog installed in subdirectory but need to create pages in root. How to use permalinks?

Have you tried to use the_permalink() filter hook?

add_filter('the_permalink', 'remove_blog');
function remove_blog($url) {
    //only affects the permalink of pages
    if(is_page()){
        return str_replace('blog/', '', $url);
    }
    return $url;
}

In combination with your current rewrite rule in the .htaccess of your root directory.

Leave a Comment