Archive-Custom-Post-Type order by Event Date, ASC, and hide events that have completed

I quess that it would be easiest for you to store date as unix timestamp in post meta – than you can easily filter posts by post meta less than current timestamp (or any other date timestamp). See this example (not exactly for your code, but you’ll catch the punch line: $args = array( ‘post_type’ … Read more

How to display archive page posts based on author_id

All you need is to use pre_get_posts action to hook to add author_id to the query based on your custom custom_user_id query var: add_action( ‘pre_get_posts’, ‘filter_by_custom_user_id’ ); function filter_by_custom_user_id( $query ) { // Apply only on frontend, for gallery post type archive, for main query and if custom_user_id query var is set. if( ! is_admin() … Read more

Custom Post Type archive (archive-{post-type}.php) is not working

I found my problem, because I’s causing the issue by myself unknowingly. I’m posting the answer for you to debug if something like this can cause the issue: I’s using the following code to include all the CPT entries to the default loop. And that’s causing the issue. It’s directing the posttype archive to default … Read more

Archive Custom Post Type

@DarrenLee, to add multiple post types on your code, you just make a change on function cpt_rewrite_rules. Create an array of your post types, put function cpt_generate_date_archives inside loop. function cpt_rewrite_rules($wp_rewrite) { $post_types = array( ‘book’, ‘movie’, ‘etc’ ); //create post_types array $rules = array(); foreach( $post_types as $post_type ) { /* generate date archives … Read more

Add archive/category results to single post page

Figured it out. A conditional in content.php in template-parts/ checked whether the content is_archive. I assume the functionality behind is_archive is whether the file was launched from archive.php. Since it wasn’t it didn’t fire. Final step was redirecting to a custom content-post-type.php in template-parts that doesn’t have the is_archive check. Seems like it all works … Read more