1

To begin with I should note that I'm fairly new to both php and editing in the WordPress-files, BUT I have actually managed to succesfully create a page template that puts out a list of all items in a custom post type.

I needed to make another one doing the exact same for another custom post type, but it just won't work.

The code is as follows:

<?php
/**
 * Template Name: Upcoming List
 *
 * Selectable from a dropdown menu on the edit page screen.
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */

get_header(); ?>

<div id="main-content" class="main-content">

<?php
  if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
    // Include the featured content template.
    get_template_part( 'featured-content' );
  }

?>

  <div id="primary" class="content-area">
    <div id="content" class="site-content" role="main">
      <div class="breadcrumbs">
        <?php
        if ( function_exists( 'yoast_breadcrumb' ) ) {
          yoast_breadcrumb();
        }
        ?>
      </div><!-- #breacdrumbs -->

            <div class="releasediv">
              <h1><?php echo get_the_title(); ?></h1>
              <?php 
                $args = array(
                  'post_type'=>'upcoming',
                  'title_li'=> __('')
                );
                wp_list_pages( $args ); 
              ?> 
            </div>
    </div><!-- #content -->
  </div><!-- #primary -->
  <?php get_sidebar( 'content' ); ?>
</div><!-- #main-content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

As mentioned, I have the other page template, which is complete identical to this except for the template name and slug mentioned in 'post_type'. I can select the template on the page I want it applied to, but it shows everything (header, breadcrumbs, etc.) but the custom post type items - it even shows the items for another post type when I change the slug to that, but not the one I want. I've triplechecked that I didn't do something as stupid as make a typo in the post slug somewhere, but nope. I even have a single-upcoming.php file for the custom post type that works just fine.

Am I missing something obvious here? Is there anyone who've tried something similar? I'm kind of baffled that reproducing the exact same steps I've done earlier isn't working.

  • is it a hierarchical post type? wp_list_pages only outputs hierarchical post types. – Milo Jan 18 '16 at 0:14
  • I was unaware of this! The other post type I tested before was hiearchical. I changed the new post type to be hierarchical and now it works - thanks :) – rpbtz Jan 18 '16 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.