I fixed this, i had to create array outside of first loop , that was mistake, Thanks alchymyth for help
This was really helpfull for me. But in my case I am trying to renew even the first three posts. Is there any way to do that?
@triplebull
are these three first posts some sort of ‘featured’?
could you paste the code of your file (index.php?) into a http://wordpress.pastebin.com/ as a starting point for further suggestions?
and a link to your site?
or even better, start a new thread with your question?
Hi alchymyth, thanks so far. There shouldn’t be anything like featured. I just want to separate two kinds of posts from each other. Here’s the link:
http://wordpress.planetfreu.de/category/allgemein/
and here the code:
1. This switches between Category and Subcategory, works:
<?php get_header(); ?>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
<?php genesis_before_loop(); ?>
<?php genesis_before_content(); ?>
<div id="content" class="hfeed">
<h1 class="cat-title">News im Bereich - <?php single_cat_title(); ?></h1>
<?php if (is_category()) {
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
// This is the Template for Category level 1
include(CHILD_DIR.'/maincategory.php');
}
else {
// This is the Template for Category level 2
include(CHILD_DIR.'/subcategory.php');
}
} ?>
</div><!-- end #content -->
<?php include(CHILD_DIR.'/sidebar-category.php'); ?>
</div><!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>
2. This is the subcategory. There should be 2 – 3 Items, each with 3 or 4 Post excerpts. Right now it doesn’t work because some content is duplicate at the second page.
<?php if (have_posts()) : ?>
<?php rewind_posts(); ?>
<?php
wp_reset_query();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat='.$cat.'&orderby=date&order=DESC&posts_per_page=3&paged='.$paged);
while (have_posts()) : the_post(); update_post_caches($posts);
$do_not_duplicate[] = $post->ID;
?>
<div <?php post_class(); ?>>
<div class="entry-content first">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'mega' ); ?></a>
<?php genesis_post_title(); ?>
<?php wpe_excerpt('wpe_excerptlenght_teaser', 'wpe_excerptmore'); ?>
</div><!-- end .entry-content -->
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?><!-- ... end of First Teasers -->
<div id="bottomposts">
<?php if (have_posts()) : ?>
<?php rewind_posts(); ?>
<?php
query_posts('cat='.$cat.'&orderby=date&order=DESC&posts_per_page=5');
while (have_posts()) : the_post(); update_post_caches($posts);
if ( !in_array( $post->ID, $do_not_duplicate ) ):
?>
<div class="postovi">
<h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
<?php wpe_excerpt('wpe_excerptlenght_short', 'wpe_excerptmore'); ?><p></p>
<a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>">Read more...</a>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php endif; ?>
</div>
<div class="pagination">
<div class="previous"><?php previous_posts_link('Previous Entries') ?></div>
<div class="next"><?php next_posts_link('Next Entries') ?></div>
</div>
Thanks a lot in advance …
puzzling is that the first click on ‘next posts’ works as expected,
showing the right posts, excluding the right ones, etc.;
and then the second click (to /page/3/) gets the 404 error.
unfortunately, i don’t have any ideas how to change this.
is there a difference how the categories are linked to these posts – in particular is the ‘6. artikel’ different in any way to ‘7. artikel’ and above?
and obviously, the question is why do you want to show posts of the same category in two different ways?
it makes kind of sense on the first page (showing the three latest in detail, and the following just as excerpts), but becomes kind of useless on the second page and further.
Hi and thanks for your support. I tried a different approach and it works well (http://wordpress.planetfreu.de/category/allgemein/). If anyone is interested in putting different appearances to excerpt on the category page – this works:
<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ($count <= 3) : ?>
<div <?php post_class(); ?>>
<div class="entry-content first">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'mega' ); ?></a>
<?php genesis_post_title(); ?>
<?php wpe_excerpt('wpe_excerptlenght_teaser', 'wpe_excerptmore'); ?>
</div><!-- end .entry-content -->
</div>
<?php elseif ($count == 4) : ?>
<div id="featured-bottom">
<h4 class="widgettitle">weitere News</h4>
<?php elseif ($count <= 7) : ?>
<div <?php post_class(); ?>>
<div class="entry-content second">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'large' ); ?></a>
<?php genesis_post_title(); ?>
<?php wpe_excerpt('wpe_excerptlenght_short', 'wpe_excerptmore'); ?>
</div><!-- end .entry-content -->
</div>
<?php elseif ($count == 8) : ?>
</div><div class="clear"></div>
<?php else : ?>
<div <?php post_class(); ?>>
<div class="entry-content third">
<?php genesis_post_title(); ?>
<?php wpe_excerpt('wpe_excerptlenght_mini', 'wpe_excerplink'); ?>
</div><!-- end .entry-content -->
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php if(is_single()) { // single-view navigation ?>
<?php $posts = query_posts($query_string); if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php previous_post_link(); ?> | <?php next_post_link(); ?>
<?php endwhile; endif; ?>
<?php } else { // archive view navigation ?>
<?php posts_nav_link(); ?>
<?php } ?>