WPCrafter Community

Find answers, ask questions, and connect with our
WordPress community around the world.

Home Community General Questions Need help for creating custom taxonomy

  • Need help for creating custom taxonomy

     Stratos updated 2 years, 2 months ago 2 Members · 2 Posts
  • alexanderbiscajin

    Member
    Dec 20, 2017 at 1:51 am

    I am creating a custom taxonomy using the code in functions.php but it’s not working properly. Can anyone help me i don’t know where i am doing mistake. I have found this code on https://www.wpblog.com/create-custom-taxonomies-in-wordpress/1 and i don’t know whether the code is not working or might be i am doing something wrong.

    //create a custom taxonomy name
    function create_cw_hierarchical_taxonomy() {
    $labels = array(
    ‘name’ => _x( ‘Topics’, ‘taxonomy general name’ ),
    ‘singular_name’ => _x( ‘Topic’, ‘taxonomy singular name’ ),
    ‘search_items’ => __( ‘Search Topics’ ),
    ‘all_items’ => __( ‘All Topics’ ),
    ‘parent_item’ => __( ‘Parent Topic’ ),
    ‘parent_item_colon’ => __( ‘Parent Topic:’ ),
    ‘edit_item’ => __( ‘Edit Topic’ ),
    ‘update_item’ => __( ‘Update Topic’ ),
    ‘add_new_item’ => __( ‘Add New Topic’ ),
    ‘new_item_name’ => __( ‘New Topic Name’ ),
    ‘menu_name’ => __( ‘Topics’ ),
    );
    // taxonomy register
    register_taxonomy(‘topics’,array(‘post’), array(
    ‘hierarchical’ => true,
    ‘labels’ => $labels,
    ‘show_ui’ => true,
    ‘show_admin_column’ => true,
    ‘query_var’ => true,
    ‘rewrite’ => array( ‘slug’ => ‘topic’ ),
    ));
    }

  • Stratos

    Member
    Dec 20, 2017 at 9:18 am

    Before the //create a custom taxonomy name you have forgoten a line. It is the add_action command so wordpress doesn't know where to hook the create_cw_hierarchical_taxonomy.

    Check again the website you took the code and you will see it.

Log in to reply.

Original Post
0 of 0 posts June 2018
Now

Stay Up To Date

Enter your name and email for the lates news, updates, and tutorials.