Support » How-To and Troubleshooting » Trouble using Taxonomies

Trouble using Taxonomies

  • Hey everyone

    Really glad to join the forum hope to meet some good people here 🙂
    i’m new to wordpress but i have experience with joomla

    i was reading this article on the codex, on custom taxonomies


    When i try placing the example taxonomy code into my functions.php file i get this error,

    Fatal error: Call to undefined function add_action() in C:\wamp\www\temp-wp\flamingweasel\wp-includes\functions.php on line 3645

    This is the function code

    function people_init() {
    	// create a new taxonomy
    			'label' => __( 'People' ),
    			'rewrite' => array( 'slug' => 'person' ),
    			'capabilities' => array('assign_terms'=>'edit_guides', 'edit_terms'=>'publish_guides')
    add_action( 'init', 'people_init' );

    i’m running my site in wamp, is there something i need to enable in order to make it work?
    what am i doing wrong here?

    Thanks alot in advance


Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer


    Hi maycontainweasel

    I think you put the code in the wrong functions.php file. You have to put it in the functions.php file in your theme folder:
    wp-content/themes/yourtheme/functions.php. If your theme doesn’t have a file called functions.php you can create one with a text editor and put the code in there.

    Remove the code from the functions.php file in the wp-includes folder.

    add_action( 'init', 'register_taxonomy_peoples' );
    function register_taxonomy_peoples() {
        $labels = array(
            'name' => _x( 'Peoples', 'peoples' ),
            'singular_name' => _x( 'People', 'peoples' ),
            'edit_item' => _x( 'Edit People', 'peoples' ),
            'update_item' => _x( 'Update People', 'peoples' ),
            'add_new_item' => _x( 'Add New People', 'peoples' ),
            'add_or_remove_items' => _x( 'Add or remove peoples', 'peoples' ),
            'menu_name' => _x( 'Peoples', 'peoples' ),
        $args = array(
            'labels' => $labels,
            'public' => true,
            'show_in_nav_menus' => true,
            'show_ui' => true,
            'show_tagcloud' => true,
            'hierarchical' => true,
            'rewrite' => true,
            'query_var' => true
        register_taxonomy( 'peoples', array('post'), $args );

    should be something like this

    Hey thanks so much for the replays everyone, very much appreciated,
    i was indeed using the wrong functions.php file! 🙂

    Thanks Robin i’ll try that out now!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trouble using Taxonomies’ is closed to new replies.