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

razvan mandu
razvan mandu
744 Points

I follow the steps but on my art page I only get the example 1 post to be displayed. I can't see example 2 and 3

example 2 and 3 exist when I access from the url like this: mydomain.com/art/example-2 but I can't see the posts on the main art page. What to do??

7 Answers

razvan mandu
razvan mandu
744 Points

When I go to All pages-->My art, I can't see anything on the edit page, only a short test paragraph I've inserted but not the actual examples (ex1, ex2, ex3).

I can only see the examples 1,2,3 when I go to the custom post type called Art (in the admin menu) But they are separate, so each example has its own URL, but they are not all on the My art page (only example1).

So what code specifically should I show you? The source to the My art Page? or maybe a specific snippet of code within that whole source page. I hope you understood my problem and thank you for your help :) You can access my site easily if you want to see, it's my name I have here .com (but it's almost empty so don't laugh XD )

Farnoosh M
Farnoosh M
10,921 Points

I have the same problem. I have followed the instructions, added 4 "art"s and also added the php files to my child theme. But when I create a page with the template "Art Page" and publish it, I see only one of the "art"s on the page.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi,

First, just need to make sure that you have the content saved in the backend. If you click the view page from the edit page do you see the content properly?

If not, can you please post up the code you're using.

Farnoosh M
Farnoosh M
10,921 Points

Hi Zac,

When I click the view page from the edit page I still only see one of the "art"s. I copied the same codes that exist in the project downloads into my child theme folder.

//art.php:

<?php
/**
 * Template Name: Art Page
 */

get_header(); ?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

            <?php /* The loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>

                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <header class="entry-header">
                        <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
                        <div class="entry-thumbnail">
                            <?php the_post_thumbnail(); ?>
                        </div>
                        <?php endif; ?>

                        <h1 class="entry-title"><?php the_title(); ?></h1>
                    </header><!-- .entry-header -->

                    <div class="entry-content">
                        <?php the_content(); ?>                     
                        <?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
                    </div><!-- .entry-content -->

                    <footer class="entry-meta">
                        <?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
                    </footer><!-- .entry-meta -->
                </article><!-- #post -->

                <?php //comments_template(); ?>
            <?php endwhile; ?>

            <?php 
                $args = array(
                    'post_type' => 'art',
                    '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', 'art' ); ?>

            <?php endwhile; endif; ?>

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

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

//content-art.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-art.php:

<?php

get_header(); ?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

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

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

<?php get_sidebar(); ?>
<?php get_footer(); ?>
Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

So when you view yoursite.com/art which is using the Art Page template you see the title of the page, content for the page, and then only one art project listed? Just want to make sure you're not looking at a single art page

Farnoosh M
Farnoosh M
10,921 Points

That's right. I have created a page called Art Pieces to show the art projects. I have added 4 but can only see one when I view the page. Here is the link to the site.

Farnoosh M
Farnoosh M
10,921 Points

I posted a reply about 3 months ago and I'm still hoping for an answer :) That's right. I have created a page called Art Pieces to show the art projects. I have added 4 but can only see one when I view the page. Here is the link to the site.

Doris Keller
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Doris Keller
Front End Web Development Techdegree Graduate 47,927 Points

Hi

I had the same problem. Because I coudn't find any answer here (no further responses after the last reply) try to find out myself and rememered that in the beginning we played around with general settings. That's here I found finely the solution: Under "Settings", "Reading", "Blog pages show at most" I had the entering of 1. I entered "10" instead and it works!