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!
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
Carl Sergile16,570 Points
Sidebar doesn't show in single-portfolio.php/Nothing shows but the title.
cc: Zac Gordon
I'm having the same problem with my code. For some reason the sidebar isn't displaying on the single-portfolio.php page. If anyone has a code that works can they paste copy and paste it for everyone to use?
<?php /* Temeplate Name: Single Page */ ?>
<?php get_header(); ?>
<section class="two-column row no-max pad"> <div class="small-12 columns"> <div class="row">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <!-- Primary Column --> <div class="small-12 medium-7 medium-offset-1 medium-push-4 columns"> <div class="primary"> <?php the_field('images'); ?> </div> </div> <!-- Secondary Column --> <div class="small-12 medium-4 medium-pull-8 columns"> <div class="secondary"> <h1><?php the_title(); ?></h1> <p><?php the_field('description'); ?></p> <hr> <p> <?php previous_post_link(); ?> <a href="<?php bloginfo(); ?>/portfolio">Back to Portfolio</a> </div> </div> <?php endwhile(); endif; ?> </div> </div>
<?php get_footer(); ?>
Hello! I was having the same issue. I followed the code, went through the questions here and still couldn't find what the problem was. all it is showing is the title. No sidebar and no images.
Initially there was an issue with setting up the CPT UI when it won't allow me to use "portfolio" as the Post Type Slug so I used "portfolios".
Then on the page-portfolio.php, when declaring the post type, I used "portfolios to match the CPT UI.
$args = array( 'post_type' => 'portfolios' ); $query = new WP_Query( $args );
What I didn't realize was wordpress uses single-$posttype.php (based on the template hierarchy), therefore the file name for the single-$posttype.php should be the same as the one used on your CPT UI and the one declared on the page-portfolio.php.
make sure these are the same:
- Post type Slug on the CPT UI
- declaration on page-portfolio.php
- filename for your single-$posttype.php
I hope this helps. Took me a while but i'm happy that I can now move one.
I had the exact same issue with choosing the post type slug name in CPT UI. I named mine 'portfoliopost'. I corrected the initial issue with WP_Query, however I ran into yet another issue when naming my single portfolio page 'single-portfolio.php', rather than 'single-portfoliopost.php'. Anyways, nice catch - Very helpful! Thank you.
Also, this post was 6months ago. How's everyone journey been since this was posted? Are you using WordPress currently to develop websites?