The Portfolio Post Type plugin makes adding a portfolio to your site super simple. You install it, set up a couple of WordPress theme files (archive-portfolio, single-portfolio…) and you’re good to go. Sometimes we want a bit of customisation, and I needed to change the slugs.

The plugin creators themselves explain how to change the category and tag slugs using filters. People wanted to change the underscores to hyphens. It’s fairly simple, you just use this code.

I needed to change the default slug as well (portfolio to our-work). You could just set up a template, and attach it to a page with a different name, but the portfolio posts themselves would still be /portfolio/post. It turned out to be simple to change, with an addition to the above code.

add_filter( 'portfolioposttype_args', 'prefix_change_portfolio_slug' );
 * Change portfolio slug for Portfolio Post Type plugin.
 * Custom to Project Name
 * @param array $args Existing arguments.
 * @return array Amended arguments.
function prefix_change_portfolio_slug( array $args ) {
    $args['rewrite']['slug'] = 'our-work';

    // Don't forget to visit Settings->Permalinks after changing these to flush the rewrite rules.
    return $args;

Make sure you go into the Permalink settings and resave them when you make any changes to this code, otherwise your new slugs won’t work.

There we have it!