• Resolved Dave Gaskin

    (@peakwebsites)


    Hi,

    I’ve got an issue I’m trying to resolve with regard to the Portfolio Plugin. It has to do with the final URL path of the individual portfolio items.

    In my website settings, under Permalinks, I have a custom URL structure set up: /blog/%postname%/. This allows my single posts (blog articles) to be structured with /blog/ as the subdirectory for all my posts.

    I have configured the Slug field in the Portfolio plugin (under Settings) to be ‘portfolio‘.

    When I click on an individual Portfolio Item, the slug for the item resolves to: /blog/portfolio/[portfolio-item]

    I do not want to include ‘/blog/’ in my portfolio items URL.

    Can you offer some advice on how to change the final URL structure of the portfolio items?

    I assume it has to do with the template type that the portfolio items assume, i.e: they are using a single-post post type. I also assume that a custom function is needed to change the behavior of the portfolio items but I’m not sure how to get started.

    Thanks,
    David

    • This topic was modified 2 years, 3 months ago by Dave Gaskin.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support SM Rafiz

    (@srafiz)

    hello @peakwebsites

    Please follow the below steps to achieve the desired permalink:

    1. Go to Plugins->Add new and install Permalink Manager Lite.
    2. Go to Tools->Permalink Manager->Permastructures tab and edit the Portfolio post type to portfolio/%portfolio%
    3. Then go to the Tools tab and click on Regenerate/Reset. Select Portfolio on the Select post types field and click on regenerate.
    4. Done. Please check your portfolio items to see the change in perma-structure.

    Thanks.

    Thread Starter Dave Gaskin

    (@peakwebsites)

    Hi Rafiz,

    Thanks for the response. I strongly prefer not to use a plugin. Is there a code snippet you can suggest that I can put in my child theme functions.php file instead?

    Plugin Support SM Rafiz

    (@srafiz)

    Hi @peakwebsites

    Please paste the below codes to your child theme’s functions.php and re-save the permalink. Hopefully, it will resolve your issue.

    /**
     * Change CPT rewrite.
     *
     * @param array  $args Post Type Args.
     * @param string $post_type Post Type.
     * @return array
     */
    function tlp_portfolio_post_type_args( $args, $post_type ) {
    	global $TLPportfolio;
    
    	if ( $post_type !== $TLPportfolio->post_type ) {
    		return $args;
    	}
    
    	$args['rewrite'] = array( 'slug' => $TLPportfolio->post_type_slug, 'with_front' => false );
    
    	return $args;
    }
    
    add_filter( 'register_post_type_args', 'tlp_portfolio_post_type_args', 10, 2 );

    Thank you.

    Thread Starter Dave Gaskin

    (@peakwebsites)

    Thank you, that worked great!

    Much appreciated!
    Dave

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How NOT to inherit custom structure permalink on portfolio item final URL’ is closed to new replies.