Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • #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.press

    #1162762

    Well 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

    #1162763

    Hey 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.

    #1162764

    if you put this to your child-Theme functions.php:

    Edit : look

    and on Permalinks change it to books and books_entries

    #1162765

    we 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 ****/

    #1162766

    maybe 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.

    #1162767

    Hey 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 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

    Here are the steps I followed:

    1. Activated Enfold Child theme
    2. FTP’ed to enfold-child/functions.php
    3. Pasted in your code, Saved the file
    4. Emptied my browser cache
    5. Reloaded the dashboard

    Did I miss something?

    #1162772

    UPDATE
    Here’s what I did that (mostly) worked:

    1. Went to Settings > Permalinks and changed the Portfolio ‘custom bases’ to “titles” and “titles-entries”
    2. 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
      
    3. 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.
    screenshot of the last hold out

    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.

    #1162844

    did 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)

    #1163229

    Good 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!

    #1163240

    can you post your child-theme functions.php here!

    #1163242

    Final 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 5 years ago by steed.
    #1163244

    Whoops – 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 ****/
    #1163968

    Hi,

    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,
    Ismael

    #1163988

    hm ? 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” )

    #1164729

    Hi,

    @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,
    Ismael

    #1256634

    @guenni007 Thank you! Your solution worked perfectly for my situation.

    • This reply was modified 4 years, 1 month ago by rlhinirv57.
    #1256958

    Hey 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 Shannon

    #1285418

    Hi I want to change the position of the portfolio in the admin Menu under the Posts?!

    #1285586

    Hey Raph,

    You mean on the backend? Please screenshot what you mean.

    Best regards,
    Jordan Shannon

Viewing 20 posts - 1 through 20 (of 20 total)
  • You must be logged in to reply to this topic.