Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm working on Custom Post Type and Genesis Child Theme. My code is

add_action( 'init', 'register_cpt_testimonial' );

function register_cpt_testimonial() {

    $labels = array( 
        'name' => _x( 'Testimonials', 'testimonial' ),
        'singular_name' => _x( 'Testimonial', 'testimonial' ),
        'add_new' => _x( 'Add New', 'testimonial' ),
        'add_new_item' => _x( 'Add New Testimonial', 'testimonial' ),
        'edit_item' => _x( 'Edit Testimonial', 'testimonial' ),
        'new_item' => _x( 'New Testimonial', 'testimonial' ),
        'view_item' => _x( 'View Testimonial', 'testimonial' ),
        'search_items' => _x( 'Search Testimonials', 'testimonial' ),
        'not_found' => _x( 'No testimonials found', 'testimonial' ),
        'not_found_in_trash' => _x( 'No testimonials found in Trash', 'testimonial' ),
        'parent_item_colon' => _x( 'Parent Testimonial:', 'testimonial' ),
        'menu_name' => _x( 'Testimonials', 'testimonial' ),
    );

    $args = array( 
        'labels' => $labels,
        'hierarchical' => true,

        'supports' => array( 'title', 'thumbnail' ),

        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 10,

        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'
    );

    register_post_type( 'testimonial', $args );
}

If I pasted the codes into function.php of Genesis Framework, worked for me. But when I used the codes into function.php of a Genesis Child, nothing was happened. Please help me to find out the mistake I made.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

i can't test this as a child theme of Genesis, but i just tested it on a child theme of Thematic and it worked fine. there isn't anything in the code that should prevent it from running. that said, i don't like registering post types as part of a theme... what if you change the theme down the line.... do you just want to lose (not lose since it will still be in the database, but won't display anymore). i've read a few posts about moving the registration of taxonomies and types to a site mu-plugin

see http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users

basically you will create a my-custom-functions.php file and put it in /wp-content/mu-plugins

and drop this code into that file. that you'll always have the tesimonial type regardless of what theme you are using. i think it is good to keep themes focused on display and not adding important site-wide functionality.

share|improve this answer
    
Good Suggestion, Thanks. –  Enthusiast Aug 26 '12 at 4:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.