Skip to content

Instantly share code, notes, and snippets.

@jamesfosker
Last active November 5, 2021 02:36
Show Gist options
  • Save jamesfosker/0de15c26e4677d2f335f32e1a6e02103 to your computer and use it in GitHub Desktop.
Save jamesfosker/0de15c26e4677d2f335f32e1a6e02103 to your computer and use it in GitHub Desktop.
Change the slugs of project post, project category and project tags, add this to your child theme functions.php, once you've changed the slug on line 5, 20 & 38, go to your dashboard and go setting/permalinks and just hit the save button to update the slugs
/*Change Project Post Type Slug*/
function ds_divi_modify_project_post_slug() {
return array(
'feeds' => true,
'slug' => 'new-slug', /*Change text between brackets*/
'with_front' => false,
);
}
add_filter( 'et_project_posttype_rewrite_args', 'ds_divi_modify_project_post_slug' );
/*Change Project Category slug*/
function ds_divi_modify_project_catagory_taxonomy() {
// get the arguments of the already-registered taxonomy
$project_category_slug_args = get_taxonomy( 'project_category' ); // returns an object
// make changes to the args
// in this example there are three changes
// again, note that it's an object
$project_category_slug_args->show_admin_column = true;
$project_category_slug_args->rewrite['slug'] = 'new-category-slug'; /*Change text between brackets*/
$project_category_slug_args_args->rewrite['with_front'] = false;
// re-register the taxonomy
register_taxonomy( 'project_category', 'project', (array) $project_category_slug_args );
}
// hook it up to 11 so that it overrides the original register_taxonomy function
add_action( 'init', 'ds_divi_modify_project_catagory_taxonomy', 11 );
/*Same as above but changes the slug of the Project Tag*/
function ds_divi_modify_project_tag_taxonomy() {
// get the arguments of the already-registered taxonomy
$project_tag_slug_args = get_taxonomy( 'project_tag' ); // returns an object
// make changes to the args
// in this example there are three changes
// again, note that it's an object
$project_tag_slug_args->show_admin_column = true;
$project_tag_slug_args->rewrite['slug'] = 'new-tag-slug'; /*Change text between brackets*/
$project_tag_slug_args_args->rewrite['with_front'] = false;
// re-register the taxonomy
register_taxonomy( 'project_tag', 'project', (array) $project_tag_slug_args );
}
// hook it up to 11 so that it overrides the original register_taxonomy function
add_action( 'init', 'ds_divi_modify_project_tag_taxonomy', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment