Used for News CPT
-
Hi, First thanks for writing this plugin.
I tried to use this on a custom post type (news) but it didn’t work by default. Here’s how I did it:
Code added in functions.php
add_filter('getarchives_join', 'news_getarchives_join', 10, 2); add_filter('getarchives_where', 'news_getarchives_where', 10, 2); function news_getarchives_where($condition_str, $r){ $condition_str = "WHERE post_type = 'news' AND post_status ='publish'"; return $condition_str; } function news_getarchives_join($condition_str, $r){ $condition_str = "JOIN wf1_icl_translations t ON t.element_id = wf1_posts.ID AND t.element_type='post_news'"; return $condition_str; }
To make it work, I needed to add the following code in collapse-archive.php to have a custom filter (start from line 86):
if ( $r['show_post_count'] ) { //$year_query = new WP_Query( 'year=' . $result->year ); $year_query_args = apply_filters( 'ca_set_year_args', 'year='.$result->year, $result ); $year_query = new WP_Query( $year_query_args ); $after = ' (' . $year_query->found_posts . ')'; }
Can you please look into this if you can include this in your next version. Thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Used for News CPT’ is closed to new replies.