custom post type not showing on archive.php and/or single.php pages in wordpress?

Custom post type are not appearing on archive page and single page. Even when using archive-post_type.php and single-post_type.php?  When you preview post it shows “not found” or “404 error” ? How to show custom post types? There may be a lot of reasons for custom posts not being shown.

Here we are going to check for possible reasons for this. These may be because of using wrong code in functions.php or something that is really unexpected.

Possible reasons for custom post types not being shown are :

 

1. First reason can be that you have not used ‘post_type’ in your query.

To use it in your query follow :

 

2. Set ‘has_archive’ as true when registering custom post type.

see How to add custom post types in wordpress ? for complete structure.

 

3. If you want these to be shown with different layout:

Please keep in mind that custom post types are not shown with regular posts. You have to modify query or use different pages. Suppose you have create custom post type “Products”. You will need to create page archive-products.php and single-products.php. So we have to use archive-post_type.php and single-post_type.php . here post_type represents slug of custom post type.

 

4. If using archive-post_type.php and single-post_type.php follow this:

Go to admin panel and select “permalinks” under “settings”. Now select “custom structure” option and paste /%category%/%postname%/ in it. See image below:

Permalink Settings ‹ Make money online — WordPress

After updating this revert back to your original / earlier setting for permalinks. By reverting I am referring to update to option selected before we made this particular change. Now check your posts if they are being shown.

Also see How to add custom page templates in wordpress.

 

Still facing problems? Feel free to discuss your problem via comments. I will be happy to help!

 

 

Apr,10,2014

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: