I have a custom post type and I'm trying to display a category page so when you click on a standard link to a category, you will see all of the posts in that category... It seems simple, and I have looked at the Wordpress hierarchy, but I can't figure out which template files I need to create...
I currently have this page pulling through my custom fields: http://ideedev.co.uk/newseed/brand/ NOT looping through custom post types. The code is essentially this:
<?php
/**
* Template name: Main Category Template
*/
?>
<?php get_header(); the_post(); ?>
<!-- Featured Image =========================================== -->
<div class="image-test-container">
<?php if ( has_post_thumbnail() ) {
// Get the post thumbnail URL
$feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
} else {
?>
<style type="text/css">.featured-image{
display:none;
}</style>
<?php
} ?>
<div id="absolute1111" style=" background: url(<?php echo $feat_image; ?>);">
<div class="centerd1111">
<h1><?php the_title(); ?></h1>
</div>
</div>
</div>
<!-- Page Content =========================================== -->
<div class="container">
<div class="row clearfix">
<div class="">
</div>
</div>
<div class="row clearfix">
<div class="level-two-intro-text">
<p><?php the_field('intro_text'); ?></p>
</div>
<div class="level-two-sub-title block__title">
<?php the_field('sub_title'); ?>
</div>
</div>
</div>
<!-- Areas =========================================== -->
<div class="container">
<div class="row clearfix">
<?php if(get_field('areas')): ?>
<?php while(has_sub_field('areas')): ?>
<div class="single-area-item six columns">
<p> <img src="<?php the_sub_field('area_icon'); ?>" style="width:100%;"> <p>
<h2> <?php the_sub_field('area_title'); ?> </h2>
<p> <?php the_sub_field('area_info'); ?> <p>
<div class="area-button"><a href="<?php the_sub_field('button_target'); ?>" class="btn btn--dark-blue" role="button"><?php the_sub_field('button_text'); ?></a></div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
However, When I click on the Portfolio button under each category, I would like it to display a page of that category...
I could make this work by creating a single template page for each category and looping through and display all posts within a specific category, but that seems like the wrong way - I'm thinking there should be one template to show the category I have just clicked on...
I think I'm getting a little confused to be honest. Thanks for looking :)
+++ EDIT +++
Here's the code I'm using for the custom post type...
register_post_type('portfolio', $args);
// Portfolio Categories
$labels = array(
'name' => _x('Portfolio Categories', 'taxonomy general name'),
'singular_name' => _x('Portfolio Category', 'taxonomy singular name'),
'search_items' => __('Search Portfolio Categories'),
'all_items' => __('All Portfolio Categories'),
'parent_item' => __('Parent Portfolio Category'),
'parent_item_colon' => __('Parent Portfolio Category:'),
'edit_item' => __('Edit Portfolio Category'),
'update_item' => __('Update Portfolio Category'),
'add_new_item' => __('Add New Portfolio Category'),
'new_item_name' => __('New Portfolio Category Name'),
'menu_name' => __('Portfolio Category'),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'category'),
);
register_taxonomy('portfolio-category', array('portfolio'), $args);