Excluding Posts (again!)
-
I have scoured the posts already available but I still can’t seem to get it. I bet some of you are fed up of seeing the same old stuff!
Im running a travel website, https://www.travelvows.com. I have a page for reviews, a page for guides, and now I have just created a new page for a personal blog part. Im creating a new template (identical to the one I am using under ‘Guides’).
On my dashboard, a ‘Post’ goes onto my ‘guides’ page, and ‘Reviews’ goes onto my ‘Reviews’ page. I am attempting for the ‘Post’ category ‘Blog’ to appear solely on my ‘Blog’ page, and not on my ‘Guides’ page.
If you haven’t glossed over yet, we’ll talk about code.
<?php /* Template Name: Blog */ ?> <?php get_header(); global $colabs_options; ?> <div id="stories-map"class="map-destinations columns col11"></div><!-- .map-destinations --> <?php echo setMap( array( 'el' => 'stories-map', 'posttype' => 'post' ) ); ?> <div class="main columns col11"> <div class="col-stories columns col11 fl"> <h2 class="ribbon"><?php _e('Blog','colabsthemes');?></h2> <?php $query_posts = new WP_query('post_type=post&paged='.$paged);?> <?php if($query_posts->have_posts()):?> <ul class="post-list"> <?php while ( $query_posts->have_posts() ) : $query_posts->the_post(); ?> <li class="posting"> <?php colabs_image(array());?> <h3><a href="<?php the_permalink();?>"><?php the_title();?></a></h3> <span class="bigred"><?php the_category(' ,');?><?php the_tags(' // ', ', ', '');?></span> <br/><?php colabs_custom_excerpt();?> <div class="more"><a href="<?php the_permalink();?>"><?php _e('read more','colabsthemes');?></a></div> </li> <?php endwhile; ?> </ul> <?php colabs_pagination('', $query_posts);?><!-- .pagination --> <?php endif;?> </div> <?php //get_sidebar();?> </div> <?php get_footer(); ?>
The above code is for my new template, which I wish to exclude all categories apart from the ID=2 (blog). I have seen some examples and tutorials online but I am not sure where to put the extra code get_post.
<?php /* Template Name: Stories */ ?> <?php get_header(); global $colabs_options; ?> <div id="stories-map"class="map-destinations columns col11"></div><!-- .map-destinations --> <?php echo setMap( array( 'el' => 'stories-map', 'posttype' => 'post' ) ); ?> <div class="main columns col11"> <div class="col-stories columns col11 fl"> <h2 class="ribbon"><?php _e('Guides','colabsthemes');?></h2> <?php $query_posts = new WP_query('post_type=post&paged='.$paged);?> <?php if($query_posts->have_posts()):?> <ul class="post-list"> <?php while ( $query_posts->have_posts() ) : $query_posts->the_post(); ?> <li class="posting"> <?php colabs_image(array());?> <h3><a href="<?php the_permalink();?>"><?php the_title();?></a></h3> <span class="bigred"><?php the_category(' ,');?><?php the_tags(' // ', ', ', '');?></span> <br/><?php colabs_custom_excerpt();?> <div class="more"><a href="<?php the_permalink();?>"><?php _e('read more','colabsthemes');?></a></div> </li> <?php endwhile; ?> </ul> <?php colabs_pagination('', $query_posts);?><!-- .pagination --> <?php endif;?> </div> <?php //get_sidebar();?> </div> <?php get_footer(); ?>
This is the code I wish to excluse JUST ID=2 (blog) and allow all others to go through.
If anyone could help me and allow me to sort this problem I would be greatly appreciative.
Thanks for reading!
Adam
- The topic ‘Excluding Posts (again!)’ is closed to new replies.