Support

Account

Home Forums General Issues Archives of custom posts based on date picker

Helping

Archives of custom posts based on date picker

  • Hi,

    I’ve created a couple of custom post types called ‘ff_events’ and ‘ff_exhibitions’ in a site I’m developing. Via a date picker using Advanced Custom Fields, I’ve added start and end dates to these posts and using those dates to display the posts in chronological order.

    To display them, I’ve created a page with a template assigned to it (template-archives.php) that uses WP_Query, ‘meta_query’ and $paged to order the posts chronologically with pagination.

    All good so far.

    However, I also need to list monthly archives for these two custom post types based on their start dates i.e. I can’t use the plugin below as it shows custom post type archives based on the post’s publish date rather than the start date custom field:

    https://wordpress.org/plugins/archives-for-custom-post-types/

    So, that’s where I’m at. I need to list monthly archives for my custom post types based on their custom field-set start dates and am lost as to how to do it!

    Does anyone know how I can go about doing this?

    Thanks,

    Osu

    Here’s a screenshot of what I’m trying to do:

    Custom post type archives organised by a date custom field set by date picker

  • I know this is an old question so I’m adding an answer for those that are looking for something similar. There are a couple of ways to accomplish this. The first is by following the example here https://www.advancedcustomfields.com/resources/creating-wp-archive-custom-field-filter/. The second is to use the actual “post date” of the post and add rewrite rules to create actual date archives for the custom post type. You can see an example of this here https://github.com/Hube2/cpt-widgets/blob/master/CPT-archives-widget.php.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Archives of custom posts based on date picker’ is closed to new replies.