Not sure I or others understand as you kind of contradict yourself. You have to use a PAGE not POSTS but you want posts. hhhmmmm…
Just take the archives.php and make it whatever you want including sidebar. There is tons of stuff on the web (Google is your friend) posted by great people how to do it.
You can list the latest post of all categories like this:
<?php
$categories = get_categories();
foreach ($categories as $cat) : ?>
<div class="wrap_cat">
<?php
// get most recent post in cat
query_posts('posts_per_page=1&cat='.$cat->cat_ID);
if (have_posts()) : while (have_posts()) : the_post();
?>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_content('continue reading...'); ?>
<?php endwhile; endif; wp_reset_query();
// get 4 most recent posts in cat offset by 1
query_posts('posts_per_page=4&offset=1&cat='.$cat->cat_ID);
if (have_posts()) : ?>
<ul class="moreposts">
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul> <!-- .moreposts -->
<?php endif; wp_reset_query();?>
</div> <!-- .wrap_cat -->
<?php endforeach; ?>
Thread Starter
jl2035
(@jl2035)
Yes it has to be page, because it has to have a unique sidebar menu – which is a widget whit widget logic like: is_page(‘XX’); Every few pages have other side menu. (widget logic is a plugin that lets me put different widgets on a different pages)
And this code:
<?php
$categories = get_categories();
foreach ($categories as $cat) : ?>
<div class="wrap_cat">
<?php
// get most recent post in cat
query_posts('posts_per_page=1&cat='.$cat->cat_ID);
if (have_posts()) : while (have_posts()) : the_post();
?>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_content('continue reading...'); ?>
<?php endwhile; endif; wp_reset_query();
// get 4 most recent posts in cat offset by 1
query_posts('posts_per_page=4&offset=1&cat='.$cat->cat_ID);
if (have_posts()) : ?>
<ul class="moreposts">
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul> <!-- .moreposts -->
<?php endif; wp_reset_query();?>
</div> <!-- .wrap_cat -->
<?php endforeach; ?>
This code made a mess out of my page(in fact any code – any <?php mark)…
It displays literally this:
$categories = get_categories();
foreach ($categories as $cat) : ?>
// get most recent post in cat
query_posts(‘posts_per_page=1&cat=’.$cat->cat_ID);
if (have_posts()) : while (have_posts()) : the_post();
?>
…and than it lists 4 latest pages i created – instead of posts…
For me this is to hard to understand…