For this project my needs are simple and so far twenty thirteen has delivered, albeit with some manageable issues.
Turning off comments was a simple one line code change, but implementing excerpts turned into something a little more involved, thanks to some newer underlying functionality that nevertheless complicated the task.
Most themes give you an option in the editor to turn off comments for both pages and posts. Not this one, you have to edit single.php and page.php and change this line of code from:
<php comments_template(); ?>
<//php comments_template(); ?>
Hat tip to noobstogeek.com for pointing the way.
The next change I wanted to make was have my category pages show excerpts instead of the entire blog posts. Normally I would just use the “More” tag, but I had already quite a number of posts created and was too lazy to go back and add the tag to the existing posts.
I’m not a big fan of the default WordPress behavior of showing the entire post on archive pages. Not only does it create duplicate content that is bad for your WordPress SEO but I think it is a suboptimal user experience. Many visitors may not care about your first blog post, so you should make it easy to scroll through a list to find one that might be more interesting to them. In my case I wanted my users to be able to scroll through recipes in various categories to quickly click on the recipe they were interested in.
When I had previously changed my category pages to show excerpts, it was an easy one line code change. But not this time.
category.php I found instead of
the_content() but rather this:
get_template_part( 'content', get_post_format()
Once I did a little research though, I found that
get_template_part was a powerful function that allowed you retrieve “parts” of a template such as navigation. You could build a little navigation.php and it would pop right in to your site. Cool. To understand what it was doing in this particular case, I should explain that in the twenty thirteen theme allows you to specify a variety of formats (ten) for your post such as “gallery”, “video”, “chat”. It really supports the more short form of blogging that social media popularizes – rather than the long form that I do here. Still it is a cool built in feature, and
get_template_part is what powers it. If you want to learn more about this, reading this post: Understanding get_template_part, is a good place to start.
All really interesting, but in my way of what I wanted to accomplish. Since
get_template_part() looks for a
content.php to pull in, that is where I went to look. There I swapped out:
content.php isn’t just used for category pages, it is used for post pages too. So my code change had the unfortunate side effect of also changing my post pages to showing excerpts rather than the full content. I fixed this by using a conditional, testing if I was dealing with a “single” page or not. Here’s my final code:
<?php if ( is_single() ) : ?>
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentythirteen' ) ); ?>
<?php else : ?>
<?php the_excerpt(); ?>
<?php endif; ?>
If there is a more elegant way to solve for this – please share it in the comments!
Kathy Alice Brown is a traffic and conversion expert specializing in SEO, Copywriting and Facebook Ad Campaigns. In her spare time she loves to get outside.