Skip to content

Instantly share code, notes, and snippets.

@cre8tivediva
Last active May 28, 2024 03:43
Show Gist options
  • Save cre8tivediva/ebad9d4d34120368d9e89a09821b0596 to your computer and use it in GitHub Desktop.
Save cre8tivediva/ebad9d4d34120368d9e89a09821b0596 to your computer and use it in GitHub Desktop.
Rename the Genesis Portfolio Slug
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Updated 5/26/2024 to reflect changes to the plugin
function rename_portfolio_custom_post_type_slug() {
// Get the post type object
$post_type_object = get_post_type_object( 'portfolio' );
// Convert the post type object to an array to manipulate its arguments
$args = (array) $post_type_object;
// Update the slug in the rewrite array
$args['rewrite']['slug'] = 'galleries';
// Unregister the original post type
unregister_post_type( 'portfolio' );
// Register the post type again with the new arguments
register_post_type( 'portfolio', $args );
}
add_action( 'init', 'rename_portfolio_custom_post_type_slug', 5 );
@tony1357
Copy link

tony1357 commented Feb 24, 2019

Thanks for the code, when I visit new permarklink, it works but the single porfolio post still display /porfolio/post/

The code does not change for single porfolio post, you can see at here https://www.canthoweb.com/dich-vu/

Please fix if possible

@BiancaNL
Copy link

Hi Anita, thanks for this snippet. I forked and adjusted the code a bit to make it work with the Genesis Pro Portfolio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment