Reputation: 854
This has been driving me crazy all day, not sure what I'm doing wrong, but perhaps one of your sharp eyes will catch it...
Basically, I have posts from a custom post type ('eac_english') that I want to archive. Using WP Template hierarchy guidelines, creating a doc called 'archive-eac_english.php' should take care of this, but when I add my code to this doc, it doesn't call the defined posts. It instead just returns a blank page.
Here's my funtion.php code:
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'eac_english',
array(
'labels' => array(
'name' => __( 'English' ),
'singular_name' => __( 'English' )
),
'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),
'taxonomies' => array('category'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'en'),
)
);
And then, in a doc labelled archive-eac_english.php I have the following:
<?php
$the_query = new WP_Query( array(
'post_type' => 'eac_english',
'orderby' => 'date',
'category_name' => 'past-featured-artist', //name of category by slug
'order' => 'DESC',
'posts_per_page' => 12)); // how many posts to show
$x = 0;
while ( $the_query->have_posts() ) :
$the_query->the_post(); ?>
<div class="home_post_box">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('grid-image'); ?></a>
<a href="<?php the_permalink(); ?>" class="home_post_text"><h3><?php the_title(); ?></h3></a>
</div><!--//home_post_box-->
<?php $x++; ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
I have an 'eac_english" post with with the category defined as 'past-featuerd-artist', but when I visit that page 'url/category/past-featured-artist/' nothing is returned.
Now if I take all the code in 'archive-eac_english.php' and add it to 'archive.php' it works no problem, but obviously that doesn't give me the option to only call the post organized under 'eac_english'.
Any help here would be greatly appreciated! cheers,
Upvotes: 0
Views: 98
Reputation: 854
Just realized I called the archive page 'archive-eac_english' I changed this to 'category-past-featured-artist' and all worked out.
Upvotes: 1