WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can taxonomies be registered in a child theme's functions.php? (4 posts)

  1. perryb
    Member
    Posted 4 years ago #

    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?

  2. demetris
    Member
    Posted 4 years ago #

    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.

  3. perryb
    Member
    Posted 4 years ago #

    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?

  4. perryb
    Member
    Posted 4 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic