custom post types and widgets
-
Hi,
I used this code in my functions.php:
add_filter( 'pre_get_posts', 'query_post_type' ); function query_post_type( $query ) { if( is_category() || is_tag() || is_home() && empty( $query->query_vars['suppress_filters'] ) ) { $query->set( 'post_type', array( 'post', 'biografie', 'nav_menu_item' /biografie is my CPT )); return $query; } }
to display the custom post types posts in the category page of a very basic custom theme. Unfortunately, this code has a drawback, when I’m in the home page, or in the category page, the recent posts widget shows only the links to the custom post types posts and some other broken links:
the category page and the home page (index.php) has a very basic code that is:
<?php get_header(); ?> <section> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <article <?php post_class() ?> id="post‐<?php the_ID(); ?>"> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> Posted on: <?php the_date(); ?> at <?php the_time(); ?> Posted in: <?php the_category(','); ?> <?php the_excerpt(); ?> Posted by: <?php the_author(); ?> </article> <?php endwhile; ?> <?php next_posts_link( '« Previous Entries' ) ?> <?php previous_posts_link( 'Next Entries »' ) ?> <?php else : ?> <p>Not Found Sorry, but you are looking for something that isn't here.</p> <?php endif; ?> </section> <?php get_sidebar(); ?> </div> <?php get_footer(); ?>
where am I doing wrong?
- The topic ‘custom post types and widgets’ is closed to new replies.