• Hi All,

    I have been recently taking advantage of the custom post types for such things as news items, and would like to take advantage of the monthly archives functionality built into WordPress.

    With standard post types, the monthly archives work perfectly fine. However, I have found that with custom post types, the monthly archives will not work correctly unless a WP standard post exists in that selected month.

    Inside my date.php file, I made a WP_Query that restricts the posts being called upon to only my custom post types “news”. My clients have grown accustomed to the “neatness” and organisation that custom post types create in the admin area of the site, as opposed to just having all of the website content as standard posts grouped by categories.

    If I have 25 posts spread across a few months inside my custom post type of “news”, date.php will not show the posts from each month unless a standard WP post also exists in that month, despite the fact that date.php loop calls upon my custom post types.

    My question is this; is there a way to trick WP into checking if a post exists for a given month across ALL post types and not just standard post types.

    I have found that my simple workaround of creating an empty, single character titled standard WP post on the first of each month will fulfil the requirements that WP is looking for when utilising date.php, but obviously this is not ideal for an automated system. I would love to simply trick WP into checking ALL post types rather than just standard posts.

    Has anyone else encountered this issue?

    Cheers in advance,
    Paul

  • The topic ‘Custom Post Types & date-based archives’ is closed to new replies.