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 trialGabriel Ward
20,222 Pointsposts not showing
my posts are not showing when I click on the Blog link in the menu.
Instead I get 'sorry, not match found for your criterial'
I can't work out what the problem is.
Thanks for any help!
Gabriel Ward
20,222 PointsSure, thanks Agustin, appreciate the help.
<?php get_header(); ?>
<section class="two-column row no-max pad">
<div class="small-12 columns">
<div class="row">
<!-- Primary Column -->
<div class="small-12 medium-7 medium-offset-1 medium-push-4 columns">
<div class="primary">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article <?php post_class('post'); ?>>
<h1><a href="s<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<h2><?php echo strip_tags(get_the_excerpt() ); ?></h2>
<ul class="post-meta no-bullet">
<li class="author">
<span class="wpt-avatar small">
<?php echo get_avatar( get_the_author_meta( 'ID' ), 24); ?>
</span>
by <?php the_author_posts_link(); ?>
</li>
<li class="cat">in <?php the_category( ', ' ); ?></li>
<li class="date">on <?php the_time( 'F j, Y'); ?></li>
</ul>
<?php if( get_the_post_thumbnail() ) : ?>
<div class="img-container">
<?php the_post_thumbnail('large'); ?>
</div>
<?php endif; ?>
</article>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no pages found' ); ?></p>
<?php endif; ?>
</div>
</div>
<!-- Secondary Column -->
<div class="small-12 medium-4 medium-pull-8 columns">
<div class="secondary">
<h2 class="module-heading">Sidebar</h2>
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
3 Answers
Agustin Grube
39,278 PointsIt's a typo, get rid of the s after href="
<h1><a href="s<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
should be:
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
Gabriel Ward
20,222 PointsStill no luck unfortunately. I'm looking through the code and can't for the life of me work out what the problem is. It was working, and then I deleted a blog post in the admin, and added a new one. That's when it stopped working. So don't know if it's something to do with admin setup?
Gabriel Ward
20,222 PointsThe individual blog posts are formatted correctly when I look at them from the admin. I've already got the single.php code.
Gabriel Ward
20,222 PointsI have it sorted. It was to do with settings in admin.
Agustin Grube
39,278 PointsHave you set a static page and a blog page in settings?
If you have not already done so, in pages, add a page called home and add a page called blog.
Then go to the admin Settings ==> Reading and select "set static page". Select the Home page you just created as the front page and select the Blog page you just created as the blog page.
The single.php is for each individual posts. The home.php will show the list of all posts. Are you having a problem with seeing individual posts or the blog page will all posts?
Gabriel Ward
20,222 PointsI had done that but for some reason they'd changed again. So I went back into the setings and put them how they should be. So now everything is working fine. Thanks for your help. I'm curious, do you work as a professional web developer?
Agustin Grube
39,278 PointsOne small nuance about WordPress is that you should stay on the page after you save something till you can visible see it was refreshed or set. If you hit save and quickly click to another page, you may lose the setting, data, or content you wanted to save.
Remember, it needs to get saved on the web server and that is not instantaneous.
Professional? I'm freelancer or work for myself. A one-man shop aka a full stack developer. Not as glamorous as it sounds. Business comes and goes.
Agustin Grube
39,278 PointsAgustin Grube
39,278 PointsCan you post the code? Should be the home.php code. You may be using a category search but not have any blog posts in that category.
Just checking, do you have sample blog posts?