I already know that you can add /blog/ on the custom structure under permalink settings. However, when I do that, it also applies to the permalink of my portfolio project types like this:


How do I make the /blog/ disappear on the project type but not on the post permalinks.

  • Did you register the portfolio type yourself, or is it from a plugin? Mar 12, 2021 at 12:07

1 Answer 1


You can use the "post_link" filter with a conditional to check the post type to modify the single posts.

For example:

add_filter( 'post_link', function($post_link, $id){
  $post = get_post( $id );
  if( is_object( $post ) && 'post' === $post->post_type ) {
    return home_url( '/blog/' . $post->post_name );
  return $post_link;
}, 10, 2 );

You would also need to modify the rewrite rules using the 'generate_rewrite_rules' filter.

Edit: This question has already been answered with a better code example here: Custom permalink structure with a prefix just for posts

Your Answer

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

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