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 trialzaraki kenpachi
2,331 PointsPortfolio page not showing portfolio images
I already follow all the instruction but it seem my page not showing any of portfolio images. Kindly please help me
below is my code :
<?php
/*
Template name: Portfolio Page
*/
?>
<?php get_header(); ?>
<section class="row">
<div class="small-12 columns text-center">
<div class="leader">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div>
</div>
</section>
<?php
$args = array(
'post-type' => 'portfolio'
);
$query = new WP_Query( '$args' );
?>
<section class="row no-max pad">
<?php if ($query->have_posts() ) : while($query->have_posts() ) : $query->the_post(); ?>
<div class="small-6 medium-4 large-3 columns grid-item">
<a href="<?php the_permalink(); ?> "><?php the_post_thumbnail( 'large' ); ?> </a>
</div>
<?php endwhile; endif; wp_reset_postdata(); ?>
</section>
<?php get_footer() ?>
2 Answers
Stephen O'Connor
22,291 PointsTry 'post_type' in your WP_Query arguments array, not 'post-type'.
Mentor Kadriu
2,409 PointsIn the admin area, go to CPT UI plugin -> Add/Edit Post types -> Edit Post Types. Scroll down till end, you will see a section called Supports and check Title .
zaraki kenpachi
2,331 Pointszaraki kenpachi
2,331 Pointsi already change to 'post_type' but nothing happen. Still not display the thumbnail
Stephen O'Connor
22,291 PointsStephen O'Connor
22,291 PointsHave you added theme support for post thumbnails in your functions.php file?
Stephen O'Connor
22,291 PointsStephen O'Connor
22,291 PointsWhat's with the mark down on the answer? :O 'post_type' is the correct syntax, not 'post-type', I don't think this merits a markdown as the original code posted was incorrect.
zaraki kenpachi
2,331 Pointszaraki kenpachi
2,331 Pointsfunctions.php
already changed as your suggestion :
Stephen O'Connor
22,291 PointsStephen O'Connor
22,291 PointsTry taking the quote marks off the $args parameter in your wp_Query.
And try this for your loop, I'm not sure you need the first '$query->' on 'have_posts'.
zaraki kenpachi
2,331 Pointszaraki kenpachi
2,331 Pointsnow i can see the thumbnails by removing quote marks off. thank you so much :)
Stephen O'Connor
22,291 PointsStephen O'Connor
22,291 PointsExcellent. Glad it's working for you now.
Don Hamilton III
31,828 PointsDon Hamilton III
31,828 PointsI was having a similar problem and this was exactly the problem. lol. Thanks for the help Stephen.
Aman Mender
11,197 PointsAman Mender
11,197 PointsTHANK YOU!!!!
'post_type', not 'post-type'!
This was my problem.