Forums

Category Posts Widget
Used with custom post types, only showing on main page? (1 post)

  1. handleisnull
    Member
    Posted 7 months ago #

    So I'm using Custom Post Types UI and have two custom post types created thus far.

    This widget works great on the home page and displays exactly what I'd expect it to, however, when navigating away from the home page the sidebar widgets added by this plugin show up empty.

    This is the code I have added to functions.php to allow my custom post types to show up in the main feed, and I suspect that the problem is that this code does not appear on the other pages, just now sure where to add it.

    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('post','movie_reviews','nav_menu_item','fiction');
        $query->set('post_type',$post_type);
    	return $query;
        }
    }

    Thanks in advance for the help.

    http://wordpress.org/extend/plugins/category-posts/

Reply

You must log in to post.

About this Plugin

About this Topic