How to filter by date & a specific custom post type post-WP 4.4?

There is no logical explanation why if( is_post_type_archive(‘news) && is_date()) should fail and not work in your situation. is_date() return true on all date archives is_post_type_archive( ‘news’ ) will return true on post type archives When you visit localhost/2016/02/?post_type=news, both of those ring true, and they will only ring true on that specific URL If … Read more

wp_get_archives() not working for my custom post type

wp_get_archive() does not work natively with custom post type, even if the official documentation let suppose it’s possible to use CPT as argument ( https://codex.wordpress.org/Template_Tags/wp_get_archives) post_type (“string”) Limit archives to a post type. Default is ‘post’. (since Version 4.4) You can find discussion and possible workaround in this stackoverflow post: https://stackoverflow.com/questions/8943251/wp-get-archives-for-custom-post-type-not-working and here: Custom Post … Read more

How we display Archives for specific categories

Add this to your functions.php file and replace ‘Uncategorized with the category name add_filter( ‘getarchives_where’, ‘wse95776_archives_by_cat’, 10, 2 ); /** * Filter the posts by category slug * @param $where * @param $r * * @return string */ function wse95776_archives_by_cat( $where, $r ){ return “WHERE wp_posts.post_type=”post” AND wp_posts.post_status=”publish” AND wp_terms.slug = ‘Uncategorized’ AND wp_term_taxonomy.taxonomy = … Read more