WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Can taxonomies be registered in a child theme’s functions.php?

[Resolved] Can taxonomies be registered in a child theme’s functions.php?

  • I am trying out example code from various tutorials for adding taxonomies to WordPress 3.0 (including some from the codex).

    For example:

    // Custom Taxonomy Code
    add_action( 'init', 'build_taxonomies', 0 );
    
    function build_taxonomies() {
    register_taxonomy( 'operating_system', 'post', array( 'hierarchical' => true, 'label' => 'Operating System', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'ram', 'post', array( 'hierarchical' => true, 'label' => 'RAM', 'query_var' => true, 'rewrite' => true ) );
    register_taxonomy( 'hard_drive', 'post', array( 'hierarchical' => true, 'label' => 'Hard Drive', 'query_var' => true, 'rewrite' => true ) );
    }

    This code does not work in the child but it does if in the parent theme’s functions.php.

    Is this meant to be the case or have I made a mistake somewhere along the line?

Viewing 3 replies - 1 through 3 (of 3 total)
  • demetris
    Participant

    @demetris

    perryb, I cannot help much with custom taxonomies (I haven’t looked into them), but I dropped your code into the functions.php of a child theme of Twenty Ten, and it works OK. The taxonomies are registered.

    That’s odd!

    I pasted it into a blank functions.php in a child theme folder with <?php … ?> wrapped round it and it didn’t even register.

    I wonder what I’ve missed?

    This is just too stupid – make sure you call name your file in your child theme “functions.php” not “function.php”!!

    Doh – thanks for dropping by demetris!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Can taxonomies be registered in a child theme’s functions.php?’ is closed to new replies.