index.php – having some categories take the_content; other the_excerpt
-
Hi,
I’m afraid I can’t work out how to solve a problem I’m having. Essentially I want the index.php to run the following query
if is category 5,8,9, or 10
get posts with the_contentelse
get posts with the_excerptAt the moment I’m using the following code for the page, but it’s returning a PHP error message on the <?php elseif ( ?> but I suspect the error is higher up than that.
<?php if (have_posts()) : ?> <?php //$post = $posts[0]; // Hack. Set $post so that the_date() works. ?> <?php /* If this is a category archive */ if (is_category()) { ?> <div class="headline_line"><h2><span><?php echo get_category_parents($cat, FALSE, ' : '); ?></span></h2></div> <?php /* If this is a monthly archive */ } elseif (is_month()) { ?> <div class="headline_line"><h2><span>Entries from <?php the_time('F Y'); ?></span></h2></div> <?php /* If this is a tag archive */ } elseif (is_tag()) { ?> <div class="headline_line"><h2><span><?php single_tag_title('Currently browsing the tag <strong>'); ?></strong>:</span></h2></div> <?php } ?> <?php while (have_posts()) : the_post(); update_post_caches($posts); ?> <?php if (is_category (array('5,8,9,10')) ) { ?> <div class="content"><h2><a class="title" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php the_content(__('Read more...')); ?> </div> <?php } else { ?> <div class="content"> <h2><a class="title" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php the_excerpt(__('Read more...')); ?><span class="read_more"><a title="Read more about: <?php the_title(); ?>" href="<?php the_permalink() ?>">»</a></span> <?php } ?> </div> <?php endwhile; ?> <?php elseif ( ?> <div class="errorbox"> <?php _e('Sorry, no posts matched your criteria.'); ?> </div> <?php endif; ?> <?php include (TEMPLATEPATH . '/navigation.php'); ?> </div></div> <?php include (TEMPLATEPATH . '/sidebar.php'); ?> <?php get_footer(); ?> </div>
Any help would be really gratefully received!
many thanks,
edd
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘index.php – having some categories take the_content; other the_excerpt’ is closed to new replies.