Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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;
    }

    #619096

    Hey!

    What do you mean by ‘broke the site’? do you have access to the php error logs?

    Regards,
    Josue

    #619351

    Hi 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

    #619736

    Hm, what happens if you rename the function unregister_taxonomy to something different like unregister_taxonomy_custom.

    Regards,
    Josue

    #623345

    That worked perfectly, thanks!

    #623658

    You are welcome, glad to help :)

    Regards,
    Josue

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Relabeling Portfolio Items Broke with New Update’ is closed to new replies.