List posts per category
-
In the following code I managed to display all the custom categories and posts under the custom page I created(page-portfolio-template.php).
<?php $args = array('post_type' => 'portfolio', 'post_per_page' => 3); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="thumbnail"><?php the_post_thumbnail('medium'); ?> </div> <h1><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></h1> <p><?php the_category();?></p> <p> <?php the_content(); ?> </p> <small>Posted on: <?php the_time('F j,Y'); ?> at <?php the_time('g:i a'); ?></small> <?php endwhile; // end while endif; ?>
What I”m struggling to think of, is:How can I print only the posts of the categories that I click?
Eg:If I click on reviews,then it prints all the posts under reviews only.At the moment if I click on a category it only display the category title.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘List posts per category’ is closed to new replies.