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

Luke Lee
Luke Lee
7,577 Points

Testimonial is not working

I downloaded the files and put them into wordpress theme folder. the testimonial just not working. is that because the wordpress version is 3.8.1?

4 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi, it seems silly, but can you double check that you have named your custom post type "testimonials" and have entered in testimonials via the admin area.

Matt Campbell
Matt Campbell
9,767 Points

The version won't have anything to do with it. Without seeing what you've done, I can't offer any assistance other than being able to say the problem isn't the WP version.

Luke Lee
Luke Lee
7,577 Points

OK, thanks, I will check the code again.

Luke Lee
Luke Lee
7,577 Points

I couldn't solve it, here are the codes,

//in content-testimonials.php
<div class="divider grid_12">
        <h5>Testimonial</h5>
    </div>
    <?php
    $args = array(
        'post_type' => 'testimonials',
        'posts_per_page' => 1,
        'orderby' => 'rand'
    );
    $the_query = new WP_Query( $args );
    ?>
    <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
        <div class="testimonial push_2 grid_10 clearfix">
            <blockquote>&ldquo; <?php the_field( 'testimonial' ); ?> &rdquo;</blockquote>
            <cite>&mdash; <?php the_field( 'name' ); ?></cite>
        </div>
    <?php endwhile; else: ?>
        <p>There are no posts or pages here</p>
    <?php endif; ?>

//----------
//----------
// on page.php
<?php get_header(); ?>

<div class="grid_12 omega clearfix">

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

        <h3><?php the_title() ;?></h3>  
        <?php the_content(); ?>
        <hr>

    <?php endwhile; else: ?>

        <p>There are no posts or pages here</p>

    <?php endif; ?>
</div>

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

<?php get_footer(); ?>

I'm having this same issue. I have testimonials in entered in and am using the same exact code. I'm not sure why they are not showing up.

Luke Lee
Luke Lee
7,577 Points

Hi, Josh: I just deleted everything and rotors the code. Don't waste time on it, it must be a very tiny typing error somewhere in your code.