Tagged: Custom Post Type, Portfolio, Rename
-
AuthorPosts
-
December 5, 2019 at 12:46 am #1162761
I’m redoing a site for an independent book publisher. Their old, creaky website uses a plugin called Toolset to have “Books” as a custom post type, with several (too many?) custom fields.
Rather than rely on another plugin, I wonder if I could rename “Portfolio Items” in the left nav bar so when they’re ready to publish a new book, they simply click Books (Portfolio Items), then Add New, then use a custom template I’ll build to create each new book.
Then when they’re done adding content, hopefully the new Book (Portfolio Item) would appear in the Portfolio (Book) Grid on the catalog page.
If it’s too complicated, do you guys recommend a specific plugin that’ll do what I’m looking for? Toolset does it, but is way overkill for what we need.
Old: jorvikpress.com
New dev site: jorvik.pressDecember 5, 2019 at 1:00 am #1162762Well you can change the label and on permalinks the slug you see in the url.
See here for Label: https://kriesi.at/support/topic/possible-to-rename-portfolio-entirely/and here is the child-theme usage : https://kriesi.at/support/topic/renaming-the-portfolio-custom-post-type-child-theme-issues/#post-564363
December 5, 2019 at 1:18 am #1162763Hey Guenni007,
Thank you! That first link looks exactly like what I’m asking about.
The child-theme URL goes to the same page as the link above it — was that intentional?Thanks again for the help! I’ll follow that path.
December 5, 2019 at 1:20 am #1162764if you put this to your child-Theme functions.php:
Edit : look
and on Permalinks change it to books and books_entries
December 5, 2019 at 1:34 am #1162765we only had to rename the function to let it work – because a redeclaration of a function that already exists is not possible : so code for you to try:
/**** Portfolio umbenennen im Dashboard ****/ add_action( 'init', 'unregister_taxonomy_for_custom_label', 30); function unregister_taxonomy_for_custom_label(){ global $wp_taxonomies; $taxonomy = 'portfolio_entries'; if ( taxonomy_exists( $taxonomy)) unset( $wp_taxonomies[$taxonomy]); } // portfolio args add_action( 'init', 'init_reg_portfolio', 50 ); function init_reg_portfolio() { add_filter('avf_portfolio_cpt_args', 'avf_portfolio_cpt_args_mod', 50, 1); $tax_args = array( "hierarchical" => true, "label" => "Books Categories", "singular_label" => "Books Category", "rewrite" => array('slug'=>_x($permalinks['portfolio_entries_taxonomy_base'],'URL slug','avia_framework'), 'with_front'=>true), "query_var" => true ); $avia_config['custom_taxonomy']['portfolio']['portfolio_entries']['args'] = $tax_args; register_taxonomy("portfolio_entries", array("portfolio"), $tax_args); } add_action( 'after_setup_theme', 'init_reg_portfolio' ); function avf_portfolio_cpt_args_mod($args) { $labels = array( 'name' => _x('Books', 'post type general name','avia_framework'), 'singular_name' => _x('Books Entry', 'post type singular name','avia_framework'), 'add_new' => _x('Add New', 'book','avia_framework'), 'add_new_item' => __('Add New Book Entry','avia_framework'), 'edit_item' => __('Edit Book Entry','avia_framework'), 'new_item' => __('New Book Entry','avia_framework'), 'view_item' => __('View Book Entry','avia_framework'), 'search_items' => __('Search Book Entries','avia_framework'), 'not_found' => __('No Book Entries found','avia_framework'), 'not_found_in_trash' => __('No Book Entries found in Trash','avia_framework'), 'parent_item_colon' => '' ); $args['labels'] = $labels; return $args; } /*** Ende ****/
December 5, 2019 at 2:13 am #1162766maybe Ismael looks over it – if there could be more replacements in the code. On my test it works everything. Even the left right Postnavigation etc.
December 5, 2019 at 2:46 am #1162767Hey Guenni007,
Thank you so much! I tried it myself but am seeing these errors:
Notice: Undefined variable: permalinks in /home/tpen/jorvik.press/wp-content/themes/enfold-child/functions.php on line 24Warning: Cannot modify header information – headers already sent by (output started at /home/tpen/jorvik.press/wp-content/themes/enfold-child/functions.php:24) in /home/tpen/jorvik.press/wp-includes/functions.php on line 5946
Here are the steps I followed:
- Activated Enfold Child theme
- FTP’ed to enfold-child/functions.php
- Pasted in your code, Saved the file
- Emptied my browser cache
- Reloaded the dashboard
Did I miss something?
December 5, 2019 at 4:07 am #1162772UPDATE
Here’s what I did that (mostly) worked:- Went to Settings > Permalinks and changed the Portfolio ‘custom bases’ to “titles” and “titles-entries”
- In the enfold-child theme, I opened functions.php and pasted in this:<br />
// portfolio args add_action( 'after_setup_theme', 'init_reg_portfolio' ); function init_reg_portfolio() { add_filter('avf_portfolio_cpt_args', 'avf_portfolio_cpt_args_mod', 50, 1); } function avf_portfolio_cpt_args_mod($args) { $labels = array( 'name' => _x('Book Titles', 'post type general name','avia_framework'), 'singular_name' => _x('Title Entry', 'post type singular name','avia_framework'), 'add_new' => _x('Add New', 'portfolio','avia_framework'), 'add_new_item' => __('Add New Title','avia_framework'), 'edit_item' => __('Edit Title Entry','avia_framework'), 'new_item' => __('New Title Entry','avia_framework'), 'view_item' => __('View Title Entry','avia_framework'), 'search_items' => __('Search Title Entries','avia_framework'), 'not_found' => __('No Title Entries found','avia_framework'), 'not_found_in_trash' => __('No Title Entries found in Trash','avia_framework'), 'parent_item_colon' => '' ); $args['labels'] = $labels; return $args; } //END
- In wp-content > themes > enfold > includes > admin I opened register-portfolio.php and made the $labels = array code block look like this:
$labels = array( 'name' => _x('Book Titles', 'post type general name','avia_framework'), 'singular_name' => _x('Title Entry', 'post type singular name','avia_framework'), 'add_new' => _x('Add New', 'portfolio','avia_framework'), 'add_new_item' => __('Add New Title','avia_framework'), 'edit_item' => __('Edit Title Entry','avia_framework'), 'new_item' => __('New Title Entry','avia_framework'), 'view_item' => __('View Title Entry','avia_framework'), 'search_items' => __('Search Title Entries','avia_framework'), 'not_found' => __('No Title Entries found','avia_framework'), 'not_found_in_trash' => __('No Title Entries found in Trash','avia_framework'), 'parent_item_colon' => '' );
[ NOTE: I’m not sure this is important, but I made the names match what I did in functions.php above ]
I said “mostly works” above because “Portfolio Categories” is still visible in the options.
I tried to follow what Ismael and mikeraymarketer were doing here to fix the same issue, but when I did it, I got errors so I walked it back.
December 5, 2019 at 9:36 am #1162844did you make sure you left the top
<?php
up there ?The purpose of a child theme solution is to leave the parent elements untouched – my code above works without changing a parent element file.
Ishmael’s code from Back then (2016) certainly worked; only the function: unregister_taxonomy() has probably become part of the parent source code by now. And that would end in an error because: A redeclaration is not possible – thats why i wrote that i had renamed the function to something different.
I have tested it by myself and you see that even on this part there is book categories.
By the way, if you have not intentionally disabled it – you can edit the functions.php via the dashboard.
Dashboard – Appearance – Theme Editor
on the right side you can choose the file which you like to edit. On default there are only two files ( style.css and functions.php)December 5, 2019 at 10:08 pm #1163229Good morning!
I did leave the <?php up at the top of the functions.php file.
When I used your code, everything worked, including “Books Categories.” The problem was that I also got errors:Notice: permalinks in /home/tpen/jorvik.press/wp-content/themes/enfold-child/functions.php on line 24 Notice: Undefined variable: permalinks in /home/tpen/jorvik.press/wp-content/themes/enfold-child/functions.php on line 24 Warning: Cannot modify header information - headers already sent by (output started at /home/tpen/jorvik.press/wp-content/themes/enfold-child/functions.php:24) in /home/tpen/jorvik.press/wp-includes/functions.php on line 5946 Warning: Cannot modify header information - headers already sent by (output started at /home/tpen/jorvik.press/wp-content/themes/enfold-child/functions.php:24) in /home/tpen/jorvik.press/wp-admin/includes/misc.php on line 1252 Warning: Cannot modify header information - headers already sent by (output started at /home/tpen/jorvik.press/wp-content/themes/enfold-child/functions.php:24) in /home/tpen/jorvik.press/wp-admin/admin-header.php on line 9
I got that error using your code before I edited register-portfolio.php and I get it now.
I wonder if there’s another plugin creating the problem.Thank you so much for your time. I’m learning a lot!
December 5, 2019 at 10:41 pm #1163240can you post your child-theme functions.php here!
December 5, 2019 at 10:47 pm #1163242Final Note for future readers:
The solution @Guenni007 provided above (adding code to enfold-child > functions.php achieves the goal (as of Enfold 4.6.3.1).
The error messages I got were caused by a custom post type plugin (Toolset Types).
In the end, I have reverted everything back to the defaults and will be using another custom post type solution to keep my team’s workflow close to what they have already learned.- This reply was modified 4 years, 11 months ago by steed.
December 5, 2019 at 10:51 pm #1163244Whoops – I didn’t see your request before posting my “Final Note.”
My functions.php was this:<?php /* * Add your own functions here. You can also copy some of the theme functions into this file. * WordPress will use those functions instead of the original functions then. */ /* CHANGES 'PORTFOLIO' POST TYPE TO 'BOOK TITLES'*/ // portfolio args /**** Portfolio umbenennen im Dashboard ****/ add_action( 'init', 'unregister_taxonomy_for_custom_label', 30); function unregister_taxonomy_for_custom_label(){ global $wp_taxonomies; $taxonomy = 'portfolio_entries'; if ( taxonomy_exists( $taxonomy)) unset( $wp_taxonomies[$taxonomy]); } // portfolio args add_action( 'init', 'init_reg_portfolio', 50 ); function init_reg_portfolio() { add_filter('avf_portfolio_cpt_args', 'avf_portfolio_cpt_args_mod', 50, 1); $tax_args = array( "hierarchical" => true, "label" => "Books Categories", "singular_label" => "Books Category", "rewrite" => array('slug'=>_x($permalinks['portfolio_entries_taxonomy_base'],'URL slug','avia_framework'), 'with_front'=>true), "query_var" => true ); $avia_config['custom_taxonomy']['portfolio']['portfolio_entries']['args'] = $tax_args; register_taxonomy("portfolio_entries", array("portfolio"), $tax_args); } add_action( 'after_setup_theme', 'init_reg_portfolio' ); function avf_portfolio_cpt_args_mod($args) { $labels = array( 'name' => _x('Books', 'post type general name','avia_framework'), 'singular_name' => _x('Books Entry', 'post type singular name','avia_framework'), 'add_new' => _x('Add New', 'book','avia_framework'), 'add_new_item' => __('Add New Book Entry','avia_framework'), 'edit_item' => __('Edit Book Entry','avia_framework'), 'new_item' => __('New Book Entry','avia_framework'), 'view_item' => __('View Book Entry','avia_framework'), 'search_items' => __('Search Book Entries','avia_framework'), 'not_found' => __('No Book Entries found','avia_framework'), 'not_found_in_trash' => __('No Book Entries found in Trash','avia_framework'), 'parent_item_colon' => '' ); $args['labels'] = $labels; return $args; } /*** Ende ****/
December 9, 2019 at 5:22 am #1163968Hi,
Thank you for the info.
One more thing. You should update the post type name and slug in these lines.
'name' => _x('Books', 'post type general name','avia_framework'), 'singular_name' => _x('Books Entry', 'post type singular name','avia_framework'),
Replace the placeholders (post type general name) with the actual name and slug of the book post type.
Best regards,
IsmaelDecember 9, 2019 at 10:30 am #1163988hm ? i did not do that Ismael and see image above: Link and my Categories Label is that way. The only thing left as portfolio is the permalink settings. ( same Image – over that red button “Änderungen speichern” )
December 11, 2019 at 7:57 am #1164729Hi,
@guenni007: Ah yes. You’re right. It doesn’t have to be the slug of the post type. The second parameter in the _x function is the context information for the translators, so the current values there are actually correct. Thank you.
Best regards,
IsmaelOctober 29, 2020 at 9:12 am #1256634@guenni007 Thank you! Your solution worked perfectly for my situation.
- This reply was modified 4 years ago by rlhinirv57.
October 30, 2020 at 2:35 am #1256958Hey rlhinirv57,
I’m glad this was resolved for you. If you need additional help, please let us know here in the forums.
Best regards,
Jordan ShannonMarch 4, 2021 at 3:50 pm #1285418Hi I want to change the position of the portfolio in the admin Menu under the Posts?!
March 5, 2021 at 4:42 am #1285586Hey Raph,
You mean on the backend? Please screenshot what you mean.
Best regards,
Jordan Shannon -
AuthorPosts
- You must be logged in to reply to this topic.