I'm trying to create a custom post type "Press" with an archive. I think I've done everything needed, yet when I go to /press url, no posts are showing up. I entered "test" in my archive-press.php, but that's not showing up either, so I assume the archive php file is not connected to the press page.

In my functions.php:

add_action( 'init', 'create_post_type' );
    function create_post_type(){
    register_post_type( 'press',
    'labels' => array(
         'name' => __('Press'),
         'singular_name' => __('Press Item'),
         'add_new' => __('Add New'),
         'add_new_item' => __('Add New Item'),
         'edit_item' => __('Edit Item'),
         'new_item' => __('New Item'),
         'all_items' => __('All Items'),
         'view_item' => __('View Items'),
         'search_items' => __('Search Press'),
         'not_found' =>  __('No Items found'),
         'not_found_in_trash' => __('No Items Found in Trash'), 
         'parent_item_colon' => '',
         'menu_name' => 'Press'
    'labels' => $press_labels,
    'publicly_queryable' => true,
    'public' => true,
    'show_ui' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => true,
    'menu_position' => 10,
    'query_var' => true,
    'has_archive' =>true,
    'supports' => array('title','thumbnail','excerpt')

My archive-press.php:

<?php get_header(); ?>
    $wp_query = new WP_Query();
    $wp_query -> query('post_type=press&showposts=20');
    while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    <div class="press-item">
    <div class="press-img"><?php the_post_thumbnail('medium');?></div>
    <div class="press-content">
    <div class="press-title"><?php single_post_title(); ?> </div>
    <div class="press-excerpt"><?php the_excerpt(); ?> </div>
    <?php endwhile;  ?>
 <?php get_footer(); ?>

My Permalink is set to url/%category%/%postname%/

What could I be doing wrong?

  • 1
    You may have to flush your permalinks. Go to Settings/Permalinks and click save to flush them. If that does not work there is something else hanging it up. Something I found wrong in you code is that you have 'labels' => $press_labels, the array you have defined before that is correct. Not sure but that could also be tripping things up? Oct 27, 2014 at 19:47
  • Flush your permalinks and then check this post. Never drop the main query for a custom one Oct 28, 2014 at 4:35

1 Answer 1


I generally include this chunk of code with my custom post types:

// Load the custom post type archive page template
add_filter( 'archive_template', 'posttype_archive_template' ) ;
function posttype_archive_template( $archive_template ) {
  global $post;
  if ( is_post_type_archive ( 'posttype' ) ) {
    if(file_exists(PLUGIN_PATH. '/archive-posttype.php'))
       $archive_template = PLUGIN_PATH. '/archive-posttype.php';
  return $archive_template;
  • And change "posttype" to the name of the post type, in this case "press"?
    – Jaeeun Lee
    Oct 27, 2014 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.