• I know this has been asked already and I will give you my example of adding in the code before the loop but it just did not work for me. So here is what I am needing to do.

    Hide a category with posts which control my home page slider. I tried a few plugins that do the job of hiding the posts from the blog page but then on the homepage slider the images are missing. The best fix for this would be to use the following code to hide the posts from the blog page completely.

    <?php wp_list_categories('exclude=5&title_li='); ?>

    Now here is the full code from my single.php

    <? /*
    Template Name: Blog
    */
    ?>
    
    <?php get_header(); ?>
    
    		<!-- BEGIN CONTENT -->
    		<div id="container_content">
    			<div id="main_content">
    		<div id="content" class="narrowcolumn" role="main">
    
    <?php wp_list_categories('exclude=5&title_li='); ?>
    
    						<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    						<?php $values = get_post_custom_values("category-include"); $cat=$values[0];  ?>
    						<div class="main_title2">
    							<h2><?php the_title(); ?></h2>
    						</div>
    						<div class="clr">&nbsp;</div>
    						<div class="clr">&nbsp;</div>
    						<?php endwhile; endif; ?>
    						<?php wp_reset_query();?>
    
    						<?php $wp_query = new WP_Query(); ?>
    						<?php $strinclude = $cat;?>
    						<?php $catinclude = 'cat=' . $strinclude ;?>
    						<?php $wp_query->query('&' . $catinclude .' &paged='.$paged); ?>
    						<?php  if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div <?php post_class() ?>>
    
    				<div class="entry">
    
    				<?php if (get_option('dynata_blog_page') == 'content'){?>
    
    					<div class="text2">
    					<div class="main_title2">
    						<div class="title2">
    						<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    						</div>
    
    						<div class="main_time">
    							<div class="date"><?php the_time('d') ?></div>
    							<div class="m-y">
    							<span class="month"><?php the_time('M') ?></span><br />
    							<?php the_time('Y') ?>
    							</div>
    						</div>
    					</div><!-- end main_title2 -->
    
    					<?php the_content(''); ?>
    					<span class="link_read">
    					<a href="<?php the_permalink() ?>" rel="bookmark">Read more</a>
    					</span>
    					</div><!-- end text -->
    
    				<?php }else{?>
    
    				<?php if (get_post_custom_values("image")) { ?>
    
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("image"); echo $values[0]; ?>&w=185&h=195&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="185px" height="195px"  />
    
    				<div class="text">
    					<div class="main_title">
    						<div class="title">
    						<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    						</div>
    
    						<div class="main_time">
    							<div class="date"><?php the_time('d') ?></div>
    							<div class="m-y">
    							<span class="month"><?php the_time('M') ?></span><br />
    							<?php the_time('Y') ?>
    							</div>
    						</div>
    					</div><!-- end main_title -->
    
    					<?php $excerpt = get_the_excerpt();?>
    					<p><?php echo string_limit_words($excerpt,200).'...';?> </p>
    					<span class="link_read">
    					<a href="<?php the_permalink() ?>" rel="bookmark">Read more</a>
    					</span>
    					</div>
    
    				<?php } else { ?>
    
    					<div class="text2">
    					<div class="main_title2">
    						<div class="title2">
    						<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    						</div>
    
    						<div class="main_time">
    							<div class="date"><?php the_time('d') ?></div>
    							<div class="m-y">
    							<span class="month"><?php the_time('M') ?></span><br />
    							<?php the_time('Y') ?>
    							</div>
    						</div>
    					</div><!-- end main_title2 -->
    
    					<?php $excerpt = get_the_excerpt();?>
    					<p><?php echo string_limit_words($excerpt,200).'...';?> </p>
    					<span class="link_read">
    					<a href="<?php the_permalink() ?>" rel="bookmark">Read more</a>
    					</span>
    					</div><!-- end text -->
    
    					<?php } ?>
    				<?php } ?>
    				</div><!-- end entry -->
    				<div class="clr"></div>
    
    		</div>
    		<?php endwhile; endif; ?>
    
    				 <?php if(function_exists('wp_pagenavi')) { ?>
    				<div class="pagination">
    				 <?php wp_pagenavi(); ?>
    				 </div>
    				 <?php }else{ ?>
    				<div class="navigation">
    					<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    					<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    				</div>
    				<?php }?>
    	</div>
    
    </div>
    			<div id="main_sidebar">
    				<?php include('sidebar/sidebar_blog.php'); ?>
    			</div><!-- end main_sidebar -->
    		</div>
    
    		<!-- END OF CONTENT -->
    
    <?php get_footer(); ?>

    Maybe im placing the template tag in the wrong place?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Hiding posts in category from blog page’ is closed to new replies.