So, jetzt setze ich noch einen drauf, weil es so schön geklappt hat: Ich würde gerne im unteren Bereich ("more interesting stuf...") eine chronologische Liste von Posts aus allen (oder auch nur bestimmten) Kategorien ausgeben. Die dürfen aber wiederum nicht bereits weiter oben (bei "recent stuff" oder in den Kategorieblöcken) ausgegeben worden sein.
Im Moment trickse ich da ein Bisschen und lasse je zwei Artikel der jeweiligen Kategorie mit einem Offset ausgeben. Das funktioniert zwar, ist aber nur innerhalb der Kategorien chronologisch, nicht über die ganze Liste
Wie das nun wieder hinbekommen?
Der Einfacheit halber hier nun dr komplette Code der home.php
<?php get_header(); ?>
<?php
global $options;
foreach ($options as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } }
?>
<div id="container">
<div id="left-div">
<div id="left-inside">
<div class="home-post-wrap">
<!--Begins recent posts section of the homepage-->
<div id="home-left"> <span class="orange-titles">most recent stuff...</span>
<!--Begind recent post (single)-->
<?php $do_not_duplicate = array(); // vor den Loops! ?>
<?php query_posts("cat=40&showposts=2"); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
$do_not_duplicate[] = $post->ID; // IDs im Loop merken
// Post ausgeben
if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
<?php static $ctr = 0;
if ($ctr == 2) { break; }
else { ?>
<h2 class="titles"><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>">
<?php the_title2('', '', true, '300') ?>
</a></h2>
<div class="post-inside"> <span class="post-info">Posted on
<?php the_time('F j, Y') ?>
in
<?php the_category(', ') ?>
</span>
<?php if(function_exists('get_the_image')) { get_the_image(array('default_size' => 'thumbnail', 'width' => '150', 'height' => '150', 'image_class' => 'alignleft')); } ?>
<?php the_content_limit(350, ""); ?>
</div>
<div style="clear:both;"></div>
<?php $ctr++; } ?>
<?php endwhile; ?>
<!--end recent post (single)-->
</div>
<!--The folloing displayes the popular/random posts on homepage-->
<div id="home-right"> <span class="orange-titles">recent forums posts</span>
<div style="clear: both;"></div>
<ul class="sidebarforumposts">
<?php sf_recent_posts_tag(8, false, true, true, true, 0, false); ?>
</ul>
</div>
</div>
<!--end random/popular posts-->
<?php else : ?>
<h2 >No Results Found</h2>
<p>Sorry, your search returned zero results. </p>
<?php endif; ?>
<!--The following code controls the category boxes-->
<!--Category Box 1-->
<?php query_posts( array ('cat' => 1,'showposts' => 2,'post__not_in' => $do_not_duplicate )); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="home-categories"> <span class="orange-titles"><?php echo $artsee_cat_one_name; ?></span> <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a><br />
<span class="post-info">Posted on
<?php the_time('F j, Y') ?>
</span>
<?php if(function_exists('get_the_image')) { get_the_image(array('default_size' => 'thumbnail', 'width' => '75', 'height' => '75', 'image_class' => 'alignleft')); } ?>
<?php the_content_limit(300, ""); ?>
</div>
<?php endwhile; ?>
<!--End Category Box 1-->
<!--Category Box 2-->
<?php query_posts( array ('cat' => 14,'showposts' => 2,'post__not_in' => $do_not_duplicate )); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="home-categories"> <span class="orange-titles"><?php echo $artsee_cat_two_name; ?></span> <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a><br />
<span class="post-info">Posted on
<?php the_time('F j, Y') ?>
</span>
<?php if(function_exists('get_the_image')) { get_the_image(array('default_size' => 'thumbnail', 'width' => '75', 'height' => '75', 'image_class' => 'alignleft')); } ?>
<?php the_content_limit(300, ""); ?>
</div>
<?php endwhile; ?>
<!--End Category Box 2-->
<div style="clear: both;"></div>
<!--Category Box 3-->
<?php query_posts( array ('cat' => 27,'showposts' => 2,'post__not_in' => $do_not_duplicate )); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="home-categories"> <span class="orange-titles"><?php echo $artsee_cat_three_name; ?></span> <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a><br />
<span class="post-info">Posted on
<?php the_time('F j, Y') ?>
</span>
<?php if(function_exists('get_the_image')) { get_the_image(array('default_size' => 'thumbnail', 'width' => '75', 'height' => '75', 'image_class' => 'alignleft')); } ?>
<?php the_content_limit(300, ""); ?>
</div>
<?php endwhile; ?>
<!--Category Box 3-->
<!--Category Box 4-->
<?php query_posts( array ('cat' => 39,'showposts' => 2,'post__not_in' => $do_not_duplicate )); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="home-categories"> <span class="orange-titles"><?php echo $artsee_cat_four_name; ?></span> <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a><br />
<span class="post-info">Posted on
<?php the_time('F j, Y') ?>
</span>
<?php if(function_exists('get_the_image')) { get_the_image(array('default_size' => 'thumbnail', 'width' => '75', 'height' => '75', 'image_class' => 'alignleft')); } ?>
<?php the_content_limit(300, ""); ?>
</div>
<?php endwhile; ?>
<!--Category Box 4-->
<div style="clear: both;"></div>
<div class="home-fullwidth-headline">
<span class="orange-titles">More interesting stuff...</span>
</div>
<!--Fullwidth box-->
<!-- 1. cat -->
<?php query_posts("cat=1&showposts=2&offset=4"); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="home-fullwidth"><span class="home-fullwidth-titles"><a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a></span><br />
<span class="post-info">Posted on
<?php the_time('F j, Y') ?>
</span>
<?php the_content_limit(100, ""); ?>
</div>
<?php endwhile; ?>
<!-- 2. cat -->
<?php query_posts("cat=14&showposts=2&offset=3"); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="home-fullwidth"><span class="home-fullwidth-titles"><a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a></span><br />
<span class="post-info">Posted on
<?php the_time('F j, Y') ?>
</span>
<?php the_content_limit(100, ""); ?>
</div>
<?php endwhile; ?>
<!-- 3. cat -->
<?php query_posts("cat=27&showposts=2&offset=3"); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="home-fullwidth"><span class="home-fullwidth-titles"><a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a></span><br />
<span class="post-info">Posted on
<?php the_time('F j, Y') ?>
</span>
<?php the_content_limit(100, ""); ?>
</div>
<?php endwhile; ?>
<!-- 4. cat -->
<?php query_posts("cat=39&showposts=2&offset=3"); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="home-fullwidth"><span class="home-fullwidth-titles"><a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a></span><br />
<span class="post-info">Posted on
<?php the_time('F j, Y') ?>
</span>
<?php the_content_limit(100, ""); ?>
</div>
<?php endwhile; ?>
<div style="clear: both;"></div>
<!--End Fullwidth box -->
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
</body>
</html>
Alles anzeigen