Hallo,
ich habe soeben meinen ersten Loop getestet (wuhu) und es klappt auch soweit.
Hier mal meine index.php
HTML
<?php get_header(); ?>
<div id="content">
<?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if ( ! have_posts() ) : ?>
<div id="post-0" class="post error404 not-found">
<h2 class="article-title"><?php _e( 'Not Found', 'redbel' ); ?></h2>
<div class="entry-content">
<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'redbel' ); ?></p>
</div><!-- .entry-content -->
</div><!-- #post-0 -->
<?php endif; ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
if (is_home())
{
query_posts("cat=8");
}
?>
<div id="post-<?php the_ID(); ?>" <?php post_class("article"); ?>>
<div class="article-corps-title">
<div class="article-top"><a href="#header" class="top-link"><?php _e('TOP','redbel');?></a></div>
<h2 class="article-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'redbel' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="article-date"><span class="month"><?php the_time('M') ?></span> <span class="day"><?php the_time('d') ?></span></div>
<div class="article-meta-autor"><?php _e('Posted by','redbel');?> <?php the_author();?> <?php _e('in','redbel');?> <?php the_category(', ');?></div>
</div>
<div class="article-corps">
<div class="article-page-contents">
<?php
ob_start();
the_content();
$contents = ob_get_clean();
echo preg_replace(array('/<\/h6/','/<h6/','/<\/h5/','/<h5/','/<(\/)*h4/','/<(\/)*h3/','/<(\/)*h2/','/<(\/)*h1/'),array('</div','<div class="h8"','</div','<div class="h7"','<$1h6','<$1h5','<$1h4','<$1h3'),$contents);
?>
</div>
<?php edit_post_link( __( 'Edit', 'redbel'), '<div class="edit-link">', '</div>' ); ?>
<div class="article-read-more"><a href="<?php the_permalink(); ?>"><?php _e('Read More','redbel');?></a></div>
<div class="article-meta-keywords"><?php the_tags();?></div>
<div class="article-meta-comments"><?php comments_popup_link(__('Comments (0)', 'redbel'), __('Comments (1)', 'redbel'), __('Comments (%)', 'redbel')); ?></div>
</div>
<div class="article-footer"></div>
</div>
<?php comments_template( '', true ); ?>
<?php endwhile; // End the loop. Whew. ?>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'redbel' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'redbel' ) ); ?></div>
</div><!-- #nav-below -->
<?php endif; ?>
</div><!-- contents-->
<?php get_sidebar();?>
<?php get_footer();?>
Alles anzeigen
Ich habe nun folgendes Problem:
Der Loop sorgt dafür, dass auf der Hauptseite nur eine Kategorie gelistet wird (in meinem Fall "Neuigkeiten"). Allerdings wird der letzte Artikel nun 2x angezeigt.
Weiß jemand wo da der Fehler liegen könnte?
Gruß