Okay
  Public Ticket #2386489
Permalinks for /blog and /portfolio
Closed

Comments

  •  1
    Daniel started the conversation

    Hi there!

    I would like to achieve the following URL structure for my site:

    • mysite/blog/{post-slug}  - for all blog posts and
    • mysite/portfolio/{portfolio-slug}  - for all portfolio items

    Is this possible? 

    The only way I found to insert a "/blog/" in the URL is via custom permalink structure - but unfortunately, this structure is also applied to portfolio items, changing their URL to: mysite/blog/portfolio/{portfolio-slug}

    Any advice or helpful suggestion is most welcome. Thanks!

    Kind regards, Daniel 

  •  1,558
    Laborator replied

    Hi Daniel,

    Can you try adding this code to the functions.php of the child  theme:

    /**
     * Set 'with_front' to false for the 'portfolio' post type.
     */
    add_filter( 'register_post_type_args', function( $args, $post_type )
    {
        if( 'portfolio' === $post_type && is_array( $args ) )
                $args['rewrite']['with_front'] = false;
        return $args;
    }, 99, 2 );
    

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group

  •  1
    Daniel replied

    Hi Art,

    thanks for your reply and support! Worked perfectly! :) For the record: after changing the .PHP file, you still need to rebuild the permalink structure (otherwise you get 404s for the new URLs) - might be a handy tip for others in similar situations. Thanks again!

    Kind regards, Daniel 

  •  1,558
    Laborator replied

    Hi Daniel,

    You're right as I forgot to mention that you need to re-save the changes, happy to hear that it worked.

    Have a great day, I will set this ticket as solved from here!

    Best regards,
    Laborator Team


      Documentation         Join Kalium Users Group