Show posts on a page based on a category and tag(s)

I’ve just recently done something like this using the Custom Post Type UI plugin and creating a template file.

The idea goes something like this…

  1. Install Custom Post Type UI, Watch the video, add a new post type called “Computer Guides”

  2. Next you’re going to create a page template which will list all your computer guides. To do this is fairly simple. You just create a PHP file, call the template name in the comments section, call your header, begin the post query and then call your sidebar and footer, if needed. Here is an example of my custom page template, you can basically copy/pase this into your own file. It doesn’t matter what you name it, as long as it’s something.php and then upload it to your theme directory.


<?php
/*
Template Name: YOUR PAGE THEME NAME
*/
?>
<?php get_header(); ?>
<div id="container" class="one-column">
<div id="content" role="main">
<div id="YOUR STYLE DIV (not mandatory)">
<h3 align="center"> YOUR PAGE TITLE </h3>
<?php 
$args = array( 'post_type' => 'YOUR CUSTOM POST TYPE SLUG', 'numberposts' => -1 );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<h2><a href="https://wordpress.stackexchange.com/questions/7021/<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endforeach; ?>
</div>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar();?>
<?php get_footer(); ?>

  1. With the dirty work out of the way, just go ahead and create a new WP page, title it “Computer Guides” and then select your new page template in the drop box to the right. Hit publish and view the page to make sure nothing weird has happened.

  2. Next go ahead and click “Add Computer Guide” on the left admin panel, which should have showed up when you created your post type. Type in the guide, and hit publish. The new guide should show up as an excerpt on your “Computer Guides” page, when a user clicks the title they will be taken to the full post.

I believe the answer above me would also work and be easier, this is how I set mine up because it was nicer for the end-user to work with. Very clear on where to post a new “Computer Guide” for instance, also separates the content rather nicely.

The downside to this method in your case might be that you would have to create a few post types and a few templates to accommodate whatever sub-categories you might have. I think the extra work is worth it to be able to have all of your posts organized on the dashboard as well as the front-end, and have them in an excerpt list instead of a long pagination.

Good luck 🙂