2

here is my problem. It's been around 2 hours that I try to have a page listing all projects (they are a Custom Post Type) so I'm trying to have an archive file named archive-projects.php but when I try to access it with /projects/ , it redirects me to the home.php instead of a 404 error. I'm kinda lost there. This is my register_post_type maybe it can help.

function projetPostType()
    {
        register_post_type('projects',
            array(
                'labels' => array(
                    'name' => __('Projects'),
                    'singular_name' => __('Project'),
                    'add_new' => __('Add project'),
                    'add_new_item' => __('Add project'),
                    'edit' => __('Edit'),
                    'edit_item' => __('Edit project'),
                    'new_item' => __('New project'),
                    'view' => __('View project'),
                    'view_item' => __('View the project'),
                    'search_items' => __('Search project'),
                    'not_found' => __('No project')
                ),
                'hierarchical' => false,
                'public' => true,
                'menu_position' => 30,
                'has_archive' => true,
                'rewrite' => array('slug' => 'projects'),
                'supports' => array('title', 'editor', 'thumbnail'),
                'description' => 'Project contains a text and title',
                'exclude_from_search' => true,
                'publicly_queryable' => false,
                'show_in_admin_bar' => true,                                            
                'register_meta_box_cb' => 'gererBoiteProjets'
            )
        );
    }

I don't have any plugin so it's not coming from there. If you need more informations, feel free to ask.

3 Answers 3

10

Flush your permalinks - by which I mean simply visit the Permalinks page under Settings.

Then check /projects again.

EDIT:

Remove

'publicly_queryable' => false,

from your arguments. It prevents rewrites.

5
  • I just visited the Permalinks section and even clicked "Save" just to be sure but no, still redirect me to home.php Aug 21, 2013 at 23:44
  • See my edited answer.
    – vancoder
    Aug 22, 2013 at 0:16
  • Yeah it worked and realized why it didn'T work, thanks a lot mate ! Aug 22, 2013 at 12:37
  • 1
    The publicly_queryable hint worked for me. Thanks!
    – cchiera
    Nov 26, 2013 at 20:39
  • Using 'hierarchical' => true was the issue for me. As soon as I changed it to false, it worked.
    – Sorin C
    Feb 9, 2017 at 23:40
0

I faced the same problem with my custom post type. After i flushed the permalink settings, i deleted the the page(which uses the template i created for custom post type) from the pages list and created a new one and used it and it was working fine.

My understanding is that when we flush, we sometimes don't know if they are actually flushed or not.

-5

Or, check if the 'Has Archive' checkbox is active.. ashamed ;-)

1
  • 2
    There is no such checkbox in WordPress. Please explain your answer.
    – fuxia
    Oct 16, 2013 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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