• I have a custom post type called ‘Podcasts’ but none of the posts are showing in the archive widget. Only the main query (blog posts) are being shown.

    I’ve tried adding this code below to include the Podcasts posts, but this only allowed them to show up in the archive template, which is great but not quite there yet.

    /* Show Podcasts posts in archive */
        add_filter('pre_get_posts', 'query_post_type');
        function query_post_type($query) {
          if(is_category() || is_tag()) {
            $post_type = get_query_var('post_type');
        	if($post_type)
        	    $post_type = $post_type;
        	else
        	    $post_type = array('nav_menu_item','post','podcasts');
            $query->set('post_type',$post_type);
        	return $query;
            }
        }

    How can I get the Podcasts posts to show up in the archive widget?

    For clarity, I’m talking about when I click the dropdown in the native archives widget. The days/months that should have podcast posts don’t even show up. Only the day/months for the blog posts show.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator t-p

    (@t-p)

    try adding this to your active theme’s functions.php

    add_filter( 'getarchives_where', 'custom_getarchives_where' );
    function custom_getarchives_where( $where ){
        $where = str_replace( "post_type = 'post'", "post_type IN ( 'post', 'videos' )", $where );
        return $clauses;
    }

    Thread Starter wpnewbie69

    (@wpnewbie69)

    I added that (also changed ‘videos’ to ‘podcasts’) and now, in the dropdown, the days/months that hold podcasts posts show up. However, when I click on those months, it takes me to the 404 template.

    Moderator t-p

    (@t-p)

    404 indicates failure to communicate with the server.

    Thread Starter wpnewbie69

    (@wpnewbie69)

    I mean the 404 WordPress template, not the 404 that shows up in the browser. Doesn’t that mean that WordPress is grabbing the wrong template possibly because the month I clicked holds no posts?

    Moderator t-p

    (@t-p)

    may be someone with more knowledge and expertise can chimein

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom post type posts don't show in archive widget’ is closed to new replies.