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 trialGabriella Toth
2,385 PointsUsing 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?
Gabriella Toth
2,385 PointsHi Colin,
Yes I should have checked that before posting, thank you! Here are the individual .php files I used:
- 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 -->
- 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(); ?>
- 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!
Colin Marshall
32,861 PointsColin Marshall
32,861 PointsWe 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!