• I’ve been doing some editing to the way the homepage looks and making it so each category shows 2 posts on the homepage. What I want to do is to be able to exclude a few of the categories on the homepage though so not every one is represented.

    <div class="home-wrapper">
        <div class="home-left">
            <!--Begin recent post-->
             <div class="home-post-wrap">
    <?php
    //for each category, show 3 posts
    $cat_args=array(
      'orderby' => 'name',
      'order' => 'ASC'
       );
    $categories=get_categories($cat_args);
      foreach($categories as $category) {
        $args=array(
          'showposts' => 2,
          'category__in' => array($category->term_id),
          'caller_get_posts'=>1
        );
        $posts=get_posts($args);
          if ($posts) {
            echo '<div class="cat-title">' . $category->name.'<div class="cat-title-right"> <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>More...</a></div></div>';
            foreach($posts as $post) {
              setup_postdata($post);
    		  ?>
    		  <div style="clear: both;"></div>
             <h2 class="titles"><a href="<?php the_permalink() ?>" title="<?php printf(__('%s','PureType'), get_the_title()) ?>">
                    <?php the_title(); ?>
                    </a></h2>
    				<?php include(TEMPLATEPATH . '/includes/postinfo-create.php'); ?>
    				<div style="clear: both;"></div>
    
    			<?php $width = 70;
    				  $height = 70;
    
    				  $classtext = '';
    				  $titletext = get_the_title();
    
    				  $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
    				  $thumb = $thumbnail["thumb"];  ?>
    
    			<?php if($thumb != '') { ?>
    				<div class="thumbnail-div">
    					<a href="<?php the_permalink() ?>" title="<?php printf(__('Permanent Link to %s','PureType'), get_the_title()) ?>">
    						<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
    					</a>
    				</div>
                <?php }  ?>
    
                <?php truncate_post(250) ?>
    
    			<div style="clear: both;"></div>
              <?php
            } // foreach($posts
          } // if ($posts
        } // foreach($categories
    ?>
            </div>
            <!--End recent post-->
        </div>
        <div class="home-right">
    
            <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Homepage") ) : ?>
            <?php endif; ?>
        </div>
    </div>

    Really appreciate it if someone could help me out.

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Exclude category on the homepage’ is closed to new replies.