Displaying multiple posts in categories
-
Hi I’m trying to figure out how to pull this off and could use any help that anyone could provide. I have a site I’m starting to put together here at https://www.randyniles.com/wordpress, if you view the 4 small icons under the header img they are all linked to a certain Category. When you click on any of them it will take you to that post which is great but I was wondering is it possible to set it up so that when you go to that specific post you can view all the other posts which are also set to that category?
Sort of like how posts show up on your homepage I think you can set up to 10 to display I’d like to be able to do something like that with these. If this is possible could someone assist?
Thank you in advance.here is the code I’m using on my index.php page which is generating those category icons on the home page
<?php get_header(); ?> <div id="main"> <!--this will begin the posting of categories that are specified--> <div id="category1"> <?php $featuredPosts = new WP_Query(); $featuredPosts->query('category_name=latest-news-updates&showposts=1'); while($featuredPosts->have_posts()) : $featuredPosts->the_post();?> <div class="category1box"> <p><?php $category = get_the_category(); echo $category[0]->cat_name; ?></p> <h3><?php the_title(); ?></h3> <p><img src="<?php echo get_post_meta($post->ID, 'featurethumb', true); ?>"/><?php the_excerpt(); ?></p> <p class="readit"><a href="<?php the_permalink() ?>">Read more</a>»</p> </div><!--end the category1box div--> <?php endwhile; ?> </div><!--end the category1 div--> <!--this will end the posting of specified categories--> <!--this will begin the posting of categories that are specified--> <div id="category2"> <?php $featuredPosts = new WP_Query(); $featuredPosts->query('category_name=mondaycover&showposts=1'); while($featuredPosts->have_posts()) : $featuredPosts->the_post();?> <div class="category2box"> <p><?php $category = get_the_category(); echo $category[0]->cat_name; ?></p> <h3><?php the_title(); ?></h3> <p><img src="<?php echo get_post_meta($post->ID, 'featurethumb', true); ?>"/><?php the_excerpt(); ?></p> <p class="readit"><a href="<?php the_permalink() ?>">Read more</a>»</p> </div><!--end the category1box div--> <?php endwhile; ?> </div><!--end the category2 div--> <!--this will end the posting of specified categories--> <!--this will begin the posting of categories that are specified--> <div id="category3"> <?php $featuredPosts = new WP_Query(); $featuredPosts->query('category_name=music-talk&showposts=1'); while($featuredPosts->have_posts()) : $featuredPosts->the_post();?> <div class="category3box"> <p><?php $category = get_the_category(); echo $category[0]->cat_name; ?></p> <h3><?php the_title(); ?></h3> <p><img src="<?php echo get_post_meta($post->ID, 'featurethumb', true); ?>"/><?php the_excerpt(); ?></p> <p class="readit"><a href="<?php the_permalink() ?>">Read more</a>»</p> </div><!--end the category1box div--> <?php endwhile; ?> </div><!--end the category2 div--> <!--this will end the posting of specified categories--> <!--this will begin the posting of categories that are specified--> <div id="category4"> <?php $featuredPosts = new WP_Query(); $featuredPosts->query('category_name=journal&showposts=1'); while($featuredPosts->have_posts()) : $featuredPosts->the_post();?> <div class="category4box"> <p><?php $category = get_the_category(); echo $category[0]->cat_name; ?></p> <h3><?php the_title(); ?></h3> <p><img src="<?php echo get_post_meta($post->ID, 'featurethumb', true); ?>"/><?php the_excerpt(); ?></p> <p class="readit"><a href="<?php the_permalink() ?>">Read more</a>»</p> </div><!--end the category1box div--> <?php endwhile; ?> </div><!--end the category2 div--> <!--this will end the posting of specified categories--> <div id="primary"> <?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?> <?php query_posts("cat=-9,-13,-14,-15,-16"); ?> <?php if(have_posts()) : while(have_posts()) : the_post(); ?> <!--this section will be for the regular posts that show on the main page--> <div class="post-item"> <img src="<?php echo get_post_meta($post->ID, "Thumbnail", true);?>" /> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p class="meta">posted by <?php the_author(); ?> on <?php the_date(); ?></p> <?php the_content('read more'); ?> <div class="numComments"> <a href="<?php comments_link(); ?>"><?php comments_number('0', '1', '%'); ?> Comments</a> </div><!--end numComments Class--> </div><!--end post-item--> <?php endwhile; ?> <?php else : ?> <p>The information you are looking for is not available.</p> <?php endif; ?> <!--this will end the regular post section--> <div id="morePrev"> find more posts>>> <?php next_posts_link('More...'); ?> <?php previous_posts_link('Previous...'); ?> </div><!--End morePrev Div--> </div><!--End Primary Div--> <?php get_sidebar(); ?> </div><!--End main--> <?php get_footer(); ?>
- The topic ‘Displaying multiple posts in categories’ is closed to new replies.