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 having trouble getting my custom post type to correctly register. It seems to be identifying as a page post type and using that template. I also can't access the archive page for it. Any idea on what's wrong?

add_action( 'init', 'register_cpt_women' );

function register_cpt_women() {

    $womenLabels = array( 
        'name' => _x( 'The Women', 'women' ),
        'singular_name' => _x( 'The Women', 'women' ),
        'add_new' => _x( 'Add New', 'women' ),
        'add_new_item' => _x( 'Add New Woman', 'women' ),
        'edit_item' => _x( 'Edit Woman', 'women' ),
        'new_item' => _x( 'New Woman', 'women' ),
        'view_item' => _x( 'View Woman', 'women' ),
        'search_items' => _x( 'Search Women', 'women' ),
        'not_found' => _x( 'No women found', 'women' ),
        'not_found_in_trash' => _x( 'No women found in Trash', 'women' ),
        'parent_item_colon' => _x( 'Parent Woman:', 'women' ),
        'menu_name' => _x( 'The Women', 'women' ),
    );

    $womenArgs = array( 
        'labels' => $womenLabels,
        'hierarchical' => false,
        'description' => 'The Women Listing',
        'supports' => array( 'title', 'editor', 'thumbnail' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 6,
        'menu_icon' => '/wp-content/themes/ssekoDesigns/assets/img/ico-jobs.png',
        '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( 'women', $womenArgs );

}
share|improve this question
    
I believe you need to make seperate templates for each display type for the new post type, like a post type of women would need a women-single.php in order to view single listings of the women cpt. You may also need archive and other templates such as women-archive.php in order for the archive display to work properly. –  Ronburgundy Jul 23 '13 at 12:17

2 Answers 2

up vote 1 down vote accepted

Go to Settings>Permalinks and re-save your permalinks. When you initialize a post type you need to refresh your rewrite rules.

share|improve this answer

Use this code

<?php
/* Testimonial */
function dyn_testimonial_post_tipe() {
    register_post_type( 'testimonial',
                array( 
                'label' => __('Testimonial'), 
                'singular_label' => __('testimonial Name'),
                '_builtin' => false,
                'public' => true, 
                'show_ui' => true,
                'show_in_nav_menus' => true,
                'hierarchical' => true,
                'capability_type' => 'page',
                'menu_icon' => get_template_directory_uri() . '/lib/post-tipe/icon/testimonial.png',
                'rewrite' => array(
                    'slug' => 'testimonial-view',
                    'with_front' => FALSE,
                ),
                'supports' => array(
                        'title',
                        'editor',
                        'thumbnail')
                        ) 
                );
    register_taxonomy('testimonial_category', 'testimonial', 
        array(
        'hierarchical' => true, 
        'label' => 'Testimonial Categories', 
        'singular_name' => 'Category', 
        "rewrite" => true, 
        "query_var" => true));
}
add_action('init', 'dyn_testimonial_post_tipe');
    // Add to admin_init function
    add_action('manage_testimonial_posts_custom_column' , 'custom_testimonial_columns', 10, 2);
    add_filter('manage_edit-testimonial_columns', 'my_testimonial_columns');
    //Add columns for Testimonial posts
function my_testimonial_columns($columns) {
    $columns = array(
        "cb" => "<input type=\"checkbox\" />",
        "title" => "Title",
        "testimonial_categories" => "Categories",
        "comments" => "<span><span class=\"vers\"><img src=\"".get_admin_url()."images/comment-grey-bubble.png\" alt=\"Comments\"></span></span>",
        "date" => "Date",

    );
    return $columns;
}
function custom_testimonial_columns( $column, $post_id ) {
    switch ( $column ) {
    case 'testimonial_categories':
        $terms = get_the_term_list( $post_id , 'testimonial_category' , '' , ',' , '' );
        if ( is_string( $terms ) ) {
            echo $terms;
        } else {
            echo 'Uncategorized';
        }
        break;
    }
}
?>
share|improve this answer

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.