Hey guys,

I am currently learning wordpress and I am having some trouble with Custom Post Types... I have added all the code for custom post types in my theme functions.php file however the links to the single posts done seem to work... they just go to my 404 page?

Can anyone help me find out why this is happening?

This is my functions.php code:

######################################################################################
##  For the port
######################################################################################
// Add new post type for Portfolio
add_action('init', 'portfolio_init');
function portfolio_init() 
{
    $labels = array(
        'name' => __( 'Portfolio'),
        'singular_name' => __('Portfolio'),
        'rewrite' => array(
            'slug' => __( 'portfolio' )
        ),
        'add_new' => _x('Add Item', 'portfolio'),
        'edit_item' => __('Edit Portfolio Item'),
        'new_item' => __('New Portfolio Item'),
        'view_item' => __('View Portfolio'),
        'search_items' => __('Search Portfolio'),
        'not_found' =>  __('No Portfolio Items Found'),
        'not_found_in_trash' => __('No Portfolio Items Found In Trash'),
        'parent_item_colon' => ''
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => true,
        'menu_position' => 5,
        'supports' => array(
            'title',
            'editor',
            'thumbnail'
        )
    );


register_post_type(__( 'portfolio' ), $args);
}



// Add custom taxonomies
add_action( 'init', 'portfolio_create_taxonomies', 0 );

function portfolio_create_taxonomies(){
    // Portfolio type
    register_taxonomy('portfolio-type', 'portfolio', array(
        'hierarchical' => true,
        'label' => 'Portfolio type',
        'singular_name' => 'Portfolio type',
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array('slug' => 'portfolio-type' )
    ));
}

Cheers
Dan

Ahh I think I have sorted it, I had a page with the same name url portfolio and it was braking the post... kinda annoying really...

I am having similar problem. When i try to open any page it shows me page not found. I didn't see any link similar to it. Please help me. :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.