Last active
May 28, 2024 03:43
-
-
Save cre8tivediva/ebad9d4d34120368d9e89a09821b0596 to your computer and use it in GitHub Desktop.
Rename the Genesis Portfolio Slug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Anita, thanks for this snippet. I forked and adjusted the code a bit to make it work with the Genesis Pro Portfolio.