You have a couple of bugs in your code and some other errors. Here are they
Firstly
Parse error: syntax error, unexpected T_STRING in ….\functions\toets.php on line 12
This is this piece of code that should not be there at all.
register taxonomy
You can simply just remove that. It has got no function there at all
Secondly, you actually need to register your class. You can do this by just simply doing this
$taxregister = new SH_Taxonomies();
Unrelated, but a bug (or actually a couple of bugs)
Notice: Use of undefined constant SH_NAME – assumed ‘SH_NAME’ in
…\functions\toets.php on line 13
, your text domain name should be in '
, so
_x( 'Category', 'Product Category', SH_NAME ),
should be
_x( 'Category', 'Product Category', 'SH_NAME' ),
Just a point of note, your text domain should be the same as the one registered in your style.css if this is in a theme
So your complete code that works should be
<?php
class SH_Taxonomies
{
function __construct()
{
// Hook into the 'init' action
add_action( 'init', array($this, 'taxonomies'), 0 ); }
// Register Custom Taxonomy
function taxonomies() {
$labels = array(
'name' => _x( 'Category', 'Product Category', 'SH_NAME' ),
'singular_name' => _x( 'Category', 'Category', 'SH_NAME' ),
'menu_name' => __( 'Category', 'SH_NAME' ),
'all_items' => __( 'All Categories', 'SH_NAME' ),
'parent_item' => __( 'Parent Category', 'SH_NAME' ),
'parent_item_colon' => __( 'Parent Category:', 'SH_NAME' ),
'new_item_name' => __( 'New Category Name', 'SH_NAME' ),
'add_new_item' => __( 'Add New Category', 'SH_NAME' ),
'edit_item' => __( 'Edit Category', 'SH_NAME' ),
'update_item' => __( 'Update Category', 'SH_NAME' ),
'separate_items_with_commas' => __( 'Separate Categories with commas', 'SH_NAME' ),
'search_items' => __( 'Search Categories', 'SH_NAME' ),
'add_or_remove_items' => __( 'Add or remove Categories', 'SH_NAME' ),
'choose_from_most_used' => __( 'Choose from the most used Categories', 'SH_NAME' ),
);
$rewrite = array(
'slug' => 'product_category',
'with_front' => true,
'hierarchical' => true,
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'rewrite' => $rewrite,
);
register_taxonomy( 'product_category', 'sh_product', $args );
}
}
$taxregister = new SH_Taxonomies();