Display categories followed by their posts
-
How could I possibly display a list of category titles and their posts below them on the index.php.
Every section DIV should be a category, with a LI list of every post.
<?php get_header(); ?>
<!-- START CATEGORY -->
<div class="section">
<!-- CATEGORY TITLE -->
<h2><?php
$category = get_the_category();
echo $category[0]->cat_name;
?></h2>-
<?php while ( have_posts() ) : the_post() ?>
-
<div class="header">
<div class="checkbox">
<input class="checkj" type="checkbox" id="c<?php the_ID(); ?>" name="cc" />
<label for="c<?php the_ID(); ?>"><span></span></label>
</div>
<h4><?php the_title(); ?><?php
$args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' =>'any', 'post_parent' => $post->ID );
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
the_attachment_link( $attachment->ID , false );
echo '<span>' . $attachment->post_date . '</span>';
}
}
?></h4>
</div>
<?php the_content(); ?>
<!-- START LIST OF POSTS IN THE CATEGORY --><?php endwhile; ?>
</div>
</div>
<?php get_footer(); ?> -
<div class="header">
- The topic ‘Display categories followed by their posts’ is closed to new replies.