I have a site with Wordpress posts and a custom post type (molinks). I have a post loop (plugin driven) that displays both posts and molinks in the same way. The problem I am trying to fix is that when the user clicks on the category tags, to see the category archive page, only the posts with that category show up (not the molinks).
To fix this I have used the following code, however it only works if there is a post with the category. i.e. if a post and a molink have category A then both will show on the category A archive page. But if only the molink has category A (and not a post) then the molink with the category does not show. In this case the template 'none' is called (line 2nd from bottom).
Any ideas? Thanks
<?php
/* Start the Loop */
while ( have_posts() ) : the_post();
$args = array(
'post_type' => array('molink', 'post'),
'category__in' => get_queried_object_id(),
'showposts' => 100
);
$custom_posts = new WP_Query( $args );
if ( $custom_posts->have_posts() ):
while ( $custom_posts->have_posts() ) : $custom_posts->the_post();?><br />
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><br />
<?php the_title(); ?></a>, <br />
<?php the_time('d M Y'); ?><br />
<?php endwhile; else: ?><br />
<p><?php _e('No posts.'); ?></p><br />
<br />
<?php endif; ?> <br />
<?php
endwhile;
?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>