Hallo Leute,
ich habe das schon bei Frank im Blog gepostet und ihn um Hilfe gebeten, leider ist er aber grade nicht da.
Ich hoffe das mir hier vllt. jemand weiterhelfen kann.
Ich baue mir grade ein Magazin-Theme worin ich mehrere Loops auf der Startseite laufen habe, diese sollen aber Dublikate ausschließen.
Hierzu habe ich bei Frank im Blog einen schönen Code schnippsel gefunden: http://bueltge.de/duplikate-im-loop-von-wordpress-filtern/.
Ich gebe auf meiner Startseite 5 Kategorien aus.
In den Kategorien befinden sich jeweils 3 Artikel (1Großer, 2 Kleine) und eine Liste.
Insgesammt sollen die letzten 10 News ausgegeben werden (die 3 Artikel und die restlichen 7 sollen als Liste dargestellt werden.).
Soweit so gut.
Ich habe es hin bekommen das er mir die ersten 3 Artikel ausgibt, in der Liste aber zeigt er mir wieder alle Artikel bis auf den Aktuellsten an (also Dublikate).
Eigentlich ist es auch Logisch da er sich ja nur auf die eine ID des ersten Beitrages bezieht.
Da ich aber pro Beitrag einen Loop habe müsste man das ganze in ein extra Array abspeichern, leider habe ich keine Ahnung wie das gehen soll.
Vllt. kann mir da jemand weiterhelfen.
Hier noch mein Code und ein Screenshot zum besseren verständnis:
http://www.stil-etage.de/screen.jpg
[FONT=Arial][size=10]<?php get_header(); ?>
<div class="content">
// Hier müsste ein Hauptloop für die Kategorie hin[/SIZE][/FONT]
[FONT=Arial][size=10] <div class="katheader"><div class="ub"><?php get_cat_name() ?> </div></div>
<div class="postbox">
<?php
$do_not_duplicate = array(); // vor den Loops Variable als Array setzen
// 1. Loop
query_posts('ca=14&showposts=1');
while ( have_posts() ) : the_post();
$do_not_duplicate[] = $post->ID; // IDs im Loop merken
?>
<div class="mainpost">
<div <?php post_class(); ?>>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img class="leadimg" src="<?php bloginfo( 'template_directory' ); ?>/script/timthumb.php?src=<?php echo get_post_meta( $post->ID, "image_value", true ); ?>&w=265&h=177&zc=1" alt="<?php the_title(); ?>" /></a>
<div class="mainposttxt">
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
<?php the_content('Weiterlesen »'); ?>
</div>
</div>
</div>
<?php endwhile;?>
[/SIZE][/FONT]
[FONT=Arial][size=10] <?php
// 2. Loop
query_posts( 'cat=14&showposts=1' );
while (have_posts()) : the_post();
if ( !in_array( $post->ID, $do_not_duplicate ) ) {
?>
<div class="firstpost">
<div <?php post_class(); ?>>
<div class="postimg">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img class="leadimg" src="<?php bloginfo( 'template_directory' ); ?>/script/timthumb.php?src=<?php echo get_post_meta( $post->ID, "image_value", true ); ?>&w=127&h=85&zc=1" alt="<?php the_title(); ?>" /></a>
</div>
<br style="clear:both;" />
<div class="posttxt">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php the_content('Weiterlesen »'); ?>
</div>
</div>
</div>
<?php }endwhile;?>
[/SIZE][/FONT]
[FONT=Arial][size=10] <?php
// 3. Loop
query_posts( 'cat=14&showposts=3' );
while (have_posts()) : the_post();
if ( !in_array( $post->ID, $do_not_duplicate ) ) {
?>
<div class="secondpost">
<div <?php post_class(); ?>>
<div class="postimg">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img class="leadimg" src="<?php bloginfo( 'template_directory' ); ?>/script/timthumb.php?src=<?php echo get_post_meta( $post->ID, "image_value", true ); ?>&w=100&h=100&zc=1" alt="<?php the_title(); ?>" /></a>
</div>
<br style="clear:both;" />
<div class="posttxt">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php the_content('Weiterlesen »'); ?>
</div>
</div>
</div>
<?php }endwhile;?>[/SIZE][/FONT]
[FONT=Arial][size=10]
<div class="postlist">
<div <?php post_class(); ?>>
<h2>Weitere [URL="news:%3C/h2%3E%3Cbr"]News:</h2><br[/URL] />
<ul>
<?php
// 3. Loop
query_posts( 'cat=14&showposts=7' );
while (have_posts()) : the_post();
if ( !in_array( $post->ID, $do_not_duplicate ) ) {
?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></li>
<?php }endwhile;?>
</ul>
</div>
</div>
<br style="clear:both;" />
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>[/SIZE][/FONT]
Alles anzeigen
Ganz großen Dank!