Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress How to Make a Website with WordPress Custom Post Types and Fields in WordPress Custom Post Type Templates

Gabriella Toth
Gabriella Toth
2,385 Points

Using theme 'Restaurateur'. Page doesn't display custom post entries?

I created the custom post types and fields, including the php files based on the video. However, for some reason, the post entries do not actually display on the website:

http://www.test.holczman.net/daily-special/

What am I doing wrong?

Colin Marshall
Colin Marshall
32,861 Points

We need to see your code for displaying the custom post types on the page. See the link in the right sidebar "Tips for asking questions" for instructions on how to post code to the forum. Thanks!

Gabriella Toth
Gabriella Toth
2,385 Points

Hi Colin,

Yes I should have checked that before posting, thank you! Here are the individual .php files I used:

  1. content-daily.php
<?php
/**
 * Template for displaying art custom post type entries
 */
?>  
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
        <div class="entry-meta">
            <p>Price: $<?php the_field('price'); ?></p>
        </div><!-- .entry-meta -->
    </header><!-- .entry-header -->
    <div class="entry-content">
        <p><img src="<?php the_field('image'); ?>" alt="Example image of <?php the_title(); ?>"></p>
        <p><?php the_field('description'); ?></p>
    </div><!-- .entry-content -->   
</article><!-- #post -->
  1. single-daily.php
<?php
get_header(); ?>
    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">
            <?php get_template_part( 'content', 'daily' ); ?>
        </div><!-- #content -->
    </div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
  1. daily.php ``` <?php /** * Template Name: Daily Specials Page */

get_header(); ?>

<div id="content" class="clearfix">

    <div id="main" class="col620 clearfix" role="main">

            <?php while ( have_posts() ) : the_post(); ?>

                <?php get_template_part( 'content', 'page' ); ?>

                <?php comments_template( '', true ); ?>

            <?php endwhile; // end of the loop. ?>

<?php $args = array( 'post_type' => 'daily', 'orderby' => 'title', 'order' => 'ASC' ); $the_query = new WP_Query( $args );
?> <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

        <?php get_template_part( 'content', 'daily' ); ?>

        <?php endwhile; endif; ?>

    </div> <!-- end #main -->

    <?php get_sidebar(); // sidebar 1 ?>

</div> <!-- end #content -->

<?php get_footer(); ?>

The last one already seems to be broken....

Thank you in advance!