Archived custom post type posts
-
Hey all,
I am trying to display archived posts from across 2 custom post types but I cannot get it to work.
To display the archive by month I use –
/** Custom function to alter the WHERE protion of the wp_get_archives() query */ add_filter('getarchives_where', array($this, 'getarchives_filter')); function getarchives_filter($where){ $where = "WHERE post_type='".POST_TYPE_NEWS."' OR post_type='".POST_TYPE_TLA."' AND post_status = 'publish'"; return $where; } $args = array( 'type' => $type, 'format' => 'custom', 'before' => '<li class="link_arrow">', 'after' => '</li>', 'limit' => $limit, 'show_post_count' => true ); wp_get_archives($args);
This displays the link just fine and creates links in this format –
https://www.mydomain.com/2011/01
But when I click the link the query that is run searchs for the Post Type
post
, which doesn’t exist on my site. Because of this the query returns true foris_404()
, meaning that I am taken to my ‘404.php’ page as opposed to the ‘archive.php’ page.I’ve tried using the
posts_where
filter and thepre_get_posts
filter, but neither seem to work. Does anybody know what I need to do to make this right?Thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Archived custom post type posts’ is closed to new replies.