Landing › Forums › Somentra (Impeka) › Feedback › Rename Portfolio
- This topic has 7 replies, 2 voices, and was last updated 4 years, 5 months ago by
Marius1989.
-
CreatorTopic
-
August 5, 2021 at 6:09 pm #427
hiegl
ParticipantHi, what would you recommend, if we need to rename the portfolio CPT? We want to call it “people” for our editors. Is there an easy way for this?
Thanks,
Bernhard -
CreatorTopic
-
AuthorReplies
-
August 5, 2021 at 10:31 pm #428
Are you talking about the backend menu item?
If so, do you only want to rename it for the editor role?A general solution could be something like this:
function wd_admin_menu_rename() { global $menu; $menu[6][0] = 'People'; } add_action( 'admin_menu', 'wd_admin_menu_rename' );Paste this to the functions.php inside your child theme.
Hope this is what you were looking for.August 9, 2021 at 10:33 am #429Thanks Marius!
I need to rename all of the related backend menu/submenu items, so that my client can use this CPT without having to deal with the term portfolio at all. I guess there are plugins for this, but a solution via functions.php would be better.An alternative would be to add a new CPT instead of reusing the portfolio. What would be your recommendation for adding new CPTs, while retaining Impekas features?
August 9, 2021 at 3:06 pm #430Also not a big fan of plugins when little code can do the job.
Is the people CPT the only CPT you need for this project? If so, I would just use the portfolio one.
I always do that in such a case in my projects, if only one CPT is needed.If you want I can quickly send you a code snippet. Just tell me exactly what you want. The more details, the better.
August 9, 2021 at 3:18 pm #431Alright, I quickly threw something together:
function give_your_function_a_custom_name_or_whatever() { global $menu; // set a global to get the wp admin menu array global $submenu; // set a global to get access to the submenu array $menu[6][0] = 'People'; // change "Portfolio" to "People" $menu[6][6] = 'dashicons-businessperson'; // change icon, you can pick another one that fits your needs more here: https://developer.wordpress.org/resource/dashicons/ $submenu['edit.php?post_type=portfolio'][5][0] = 'Overview'; // change "Portfolio Items" to "Overview" $submenu['edit.php?post_type=portfolio'][10][0] = 'Add Person'; // change "Add New" to "Add Person" $submenu['edit.php?post_type=portfolio'][15][0] = 'People Fields'; // change "Portfolio Categories" to "People Categories" $submenu['edit.php?post_type=portfolio'][16][0] = 'People Categories'; // change "Portfolio Fields" to "People Fields" } add_action( 'admin_menu', 'give_your_function_a_custom_name_or_whatever' );If you want the changes only on the editor role appear, wrap the above code inside the following one:
if (current_user_can('editor')) { //here goes the code from above }Tell me if there is anything else you still need.
August 9, 2021 at 3:27 pm #432PS: You can always check the menu items array inside the wp admin dashboard for further modification. Just paste this inside your functions.php temporarily. It only will affect your backend.
Having this simple overview makes it quite easy to make required changes to specific areas.
if (!function_exists('debug_admin_menus')): function debug_admin_menus() { global $submenu, $menu, $pagenow; if ( current_user_can('manage_options') ) { // enable for admin role if( $pagenow == 'index.php' ) { // puts the menu array list inside the WP admin dashboard echo '<pre>'; print_r( $menu ); echo '</pre>'; // main menu items echo '<pre>'; print_r( $submenu ); echo '</pre>'; // submenu items } } } add_action( 'admin_notices', 'debug_admin_menus' ); endif;August 10, 2021 at 8:21 am #433Thanks Marius, I will try these code snippets. Will probably take some time though.
Btw. what is your preference, if we have to create several new CPT? Would you go with a plugin (which one) then or use custom code as well?
August 10, 2021 at 8:44 am #434I prefer to create new CPT’s with custom functions, since it is really easy and avoids all unnecessary bloat most plugins bring along.
If you want to go the plugin route, “Custom Post Type UI” could be the one you are looking for.
No matter what, both solutions are summarized pretty well in the following article:
wpbeginner DOT com/wp-tutorials/how-to-create-custom-post-types-in-wordpress/I recommend to have a look into the code of Impeka and check how the team integrated the CPT’s inside the theme so you there is just a very small chance of making errors by replicating this procedure.
-
AuthorReplies
- You must be logged in to reply to this topic.


