Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #563903

    I want to rename the Portfolio cpt to something more useful for my client. I reviewed the support thread and found the original cpt registration file is enfold/includes/admin/register-portfolio.php

    Here’s my problem: When I make the appropriate changes to the you register-portfolio.php file it works. However, I can’t get the theme to override the portfolio cpt labels when using my child theme.

    I obviously want the modified register-portfolio.php file to reside in my child theme so the changes won’t be overridden when Enfold is updated. But I cannot get the modified file to override the parent theme. It’s possibly because the original file is in a sub-folder.

    I’ve done a lot of research online and still can’t get it fixed. Please advise?

    #564363

    Hi mikeraymarketer,

    Are you trying to change the Portfolio permalinks? If so you can change them under Settings–>Permalinks–>Portfolio Entry Settings

    Best regards,
    Rikard

    #564367

    I changed the permalinks already.

    Now I want to change the label in the admin and related sections from Portfolio to Inductees for a Hall of Fame museum client. It just makes it easier for them to understand and deal with when the custom post type is labeled properly.

    They have already uploaded content under the Portfolio CPT so creating a new CPT called Inductees is the wrong way to go.

    #565237

    Hey!

    Please add this in the child theme’s functions.php file:

    // 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('Hall of Fame', 'post type general name','avia_framework'),
    		'singular_name' => _x('Hall of Fame Entry', 'post type singular name','avia_framework'),
    		'add_new' => _x('Add New', 'portfolio','avia_framework'),
    		'add_new_item' => __('Add New Portfolio Entry','avia_framework'),
    		'edit_item' => __('Edit Portfolio Entry','avia_framework'),
    		'new_item' => __('New Portfolio Entry','avia_framework'),
    		'view_item' => __('View Portfolio Entry','avia_framework'),
    		'search_items' => __('Search Portfolio Entries','avia_framework'),
    		'not_found' =>  __('No Portfolio Entries found','avia_framework'),
    		'not_found_in_trash' => __('No Portfolio Entries found in Trash','avia_framework'),
    		'parent_item_colon' => ''
    	);
    
    	$args['labels'] = $labels;
    	return $args;
    }

    Adjust the values as needed.

    Regards,
    Ismael

    #565243

    @ismael, thanks your code worked for the most part.

    The only issue now is that the label for categories still reads “Portfolio Categories”. How can I change that label too?

    #565897

    Hi!

    Replace the code with this:

    function unregister_taxonomy(){
    	global $wp_taxonomies;
    	$taxonomy = 'portfolio_entries';
    	if ( taxonomy_exists( $taxonomy))
    		unset( $wp_taxonomies[$taxonomy]);
    }
    add_action( 'init', 'unregister_taxonomy', 30);
    
    // 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" => "Hall of Fame Categories",
    		"singular_label" => "Hall of Fame 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);
    }
    
    function avf_portfolio_cpt_args_mod($args) {
    	$labels = array(
    		'name' => _x('Hall of Fame', 'post type general name','avia_framework'),
    		'singular_name' => _x('Hall of Fame Entry', 'post type singular name','avia_framework'),
    		'add_new' => _x('Add New', 'portfolio','avia_framework'),
    		'add_new_item' => __('Add New Portfolio Entry','avia_framework'),
    		'edit_item' => __('Edit Portfolio Entry','avia_framework'),
    		'new_item' => __('New Portfolio Entry','avia_framework'),
    		'view_item' => __('View Portfolio Entry','avia_framework'),
    		'search_items' => __('Search Portfolio Entries','avia_framework'),
    		'not_found' =>  __('No Portfolio Entries found','avia_framework'),
    		'not_found_in_trash' => __('No Portfolio Entries found in Trash','avia_framework'),
    		'parent_item_colon' => ''
    	);
    
    	$args['labels'] = $labels;
    	return $args;
    }
    

    Adjust the value as needed.

    Cheers!
    Ismael

    #566053

    @ismael, the code does change the taxonomy label but keeps the “portfolio” label for everything else.

    However, thanks to your code, I was able to figure out how to solve the problem. I added the following at line 27:

    add_action( 'after_setup_theme', 'init_reg_portfolio' );

    So now the complete code is as follows:

    function unregister_taxonomy(){
    	global $wp_taxonomies;
    	$taxonomy = 'portfolio_entries';
    	if ( taxonomy_exists( $taxonomy))
    		unset( $wp_taxonomies[$taxonomy]);
    }
    add_action( 'init', 'unregister_taxonomy', 30);
    
    // 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" => "Hall of Fame Categories",
    		"singular_label" => "Hall of Fame 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('Hall of Fame', 'post type general name','avia_framework'),
    		'singular_name' => _x('Hall of Fame Entry', 'post type singular name','avia_framework'),
    		'add_new' => _x('Add New', 'portfolio','avia_framework'),
    		'add_new_item' => __('Add New Portfolio Entry','avia_framework'),
    		'edit_item' => __('Edit Portfolio Entry','avia_framework'),
    		'new_item' => __('New Portfolio Entry','avia_framework'),
    		'view_item' => __('View Portfolio Entry','avia_framework'),
    		'search_items' => __('Search Portfolio Entries','avia_framework'),
    		'not_found' =>  __('No Portfolio Entries found','avia_framework'),
    		'not_found_in_trash' => __('No Portfolio Entries found in Trash','avia_framework'),
    		'parent_item_colon' => ''
    	);
    
    	$args['labels'] = $labels;
    	return $args;
    }

    I’m only mention it and reposted the code in case others find this thread in the future.

    I appreciate your assistance with this and you can mark this thread resolved.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Renaming The Portfolio Custom Post Type – Child Theme Issues’ is closed to new replies.