0
votes

I'm trying to create a new custom type named "projects" but my permalinks don't work. This is my code :

function register_post_types() {
        $labels = array(
                    ...
                );

        $args = array(
            'labels' => $labels,
            'public' => true,
                        'has_archive' => false,
                        'rewrite' => array('with_front' => false, 'feeds' => false, 'pages' => false),
                        'supports' => array(
                            'title',
                            'editor',
                            'thumbnail',
                            'excerpt',
                            'comments'
                            )
                );

        register_post_type( 'projects', $args);      

I get a 404 with the url http://website.com/projects/my-project even by manually changing the permalinks (Post name => Numeric => Post name).

When debug (I use the Dev4press trick : http://www.dev4press.com/2012/tutorials/wordpress/practical/debug-wordpress-rewrite-rules-matching/) here are my results :

<!-- Request: projects/my-project -->
<!-- Matched Rewrite Rule: projects/([^/]+)(/[0-9]+)?/?$ -->
<!-- Matched Rewrite Query: projects=my-project&amp;page= -->
<!-- Loaded Template: 404.php -->

Can you help me please ?

Edit : Strangely if I replace

'rewrite' => array('with_front' => false, 'feeds' => false, 'pages' => false)

with

'rewrite' => array('slug' => 'p', 'with_front' => false, 'feeds' => false, 'pages' => false)

I can access to http://website.com/p/my-project/, but if I change the slug with 'projects' I can't access to http://website.com/projects/my-project/ :(

1

1 Answers

0
votes

go to Settings > Permalinks in the admin panel. click on save button. and see what will happen.....