-
AuthorPosts
-
April 18, 2016 at 5:22 pm #616690
Hi,
On my site, I had been using a code snippet in my child theme’s functions.php file to change the label of “Portfolio Items” in the backend to “Stallions”. After the update to 3.5.2 and WP 4.5, that code broke the site. I am copying my code below that worked before the update. Can you please let me know what code I should use to make the label change on the new theme version? Thanks!
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” => “Stallion Categories”,
“singular_label” => “Stallion 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(‘Stallions’, ‘post type general name’,’avia_framework’),
‘singular_name’ => _x(‘Stallion’, ‘post type singular name’,’avia_framework’),
‘add_new’ => _x(‘Add New’, ‘portfolio’,’avia_framework’),
‘add_new_item’ => __(‘Add New Stallion’,’avia_framework’),
‘edit_item’ => __(‘Edit Stallion’,’avia_framework’),
‘new_item’ => __(‘New Stallion Entry’,’avia_framework’),
‘view_item’ => __(‘View Stallion Entry’,’avia_framework’),
‘search_items’ => __(‘Search Stallion Entries’,’avia_framework’),
‘not_found’ => __(‘No Stallion Entries found’,’avia_framework’),
‘not_found_in_trash’ => __(‘No Stallion Entries found in Trash’,’avia_framework’),
‘parent_item_colon’ => ”
);$args[‘labels’] = $labels;
return $args;
}April 21, 2016 at 12:11 pm #619096Hey!
What do you mean by ‘broke the site’? do you have access to the php error logs?
Regards,
JosueApril 21, 2016 at 8:36 pm #619351Hi Josue,
When this code is in my child theme’s functions.php file, I get only a white screen with the following error:
Fatal error: Cannot redeclare unregister_taxonomy() (previously declared in /home/tommytow/public_html/wp-includes/taxonomy.php:506) in /home/tommytow/public_html/wp-content/themes/ttf-child/functions.php on line 13
My line 13 is labeled below with the <–:
function unregister_taxonomy(){
global $wp_taxonomies;
$taxonomy = ‘portfolio_entries’;
if ( taxonomy_exists( $taxonomy))
unset( $wp_taxonomies[$taxonomy]);
} <– this is line 13 in my functions.php
add_action( ‘init’, ‘unregister_taxonomy’, 30);// portfolio args
Thanks,
Kevin
April 22, 2016 at 10:56 am #619736Hm, what happens if you rename the function
unregister_taxonomy
to something different likeunregister_taxonomy_custom
.Regards,
JosueApril 27, 2016 at 9:16 pm #623345That worked perfectly, thanks!
April 28, 2016 at 12:51 pm #623658You are welcome, glad to help :)
Regards,
Josue -
AuthorPosts
- The topic ‘Relabeling Portfolio Items Broke with New Update’ is closed to new replies.