The entry excerpt

My internet was having an unexplained “maintainance” down time yesterday. It really sucks not having internet for an entire day, AND at the same time, not get a proper explanation for it from tech support. Anyway, as they say, shit happens. So, it’s back to business as usual ๐Ÿ™‚

I guess I’m a bit lucky to be able to address two concerns in one post: both questions actually pertain to the same concept: The the_excerpt template tag within the WP loop. Josie’s and Nikita’s questions are different by nature, but can be answered using the same concept.

Oh, before anything… Thank you Nikita for pointing it out to me. I’ve released an updated version (v.1.1) of the Dapit Hapon theme. The release doesn’t include any drastic changes, I just added a class in the CSS to make the protected single page look better. I wouldn’t have noticed it if it weren’t for Nikita’s question ๐Ÿ™‚

Anyway, going back.

If you’ve already looked at the index.php and the single.php pages of this theme, you will notice that I used different template tags for the entry text. In the index.php one, I used the the_excerpt template tag, while on the single page, I used the_content.

So basically, that’s the reason why you only get the excerpt when you’re on the homepage. It’s actually a personal preferrenceโ€”I don’t like loading everything (like a hundred lines of text) when my index page is first visited. I don’t know… I guess this is where my web designer side gets the better of me ๐Ÿ™‚ I suppose the mentality that “a properly optimized site should fit in a 1.44mb diskette” of the early Internet years where high-speed connections are still ridiculously expensive hasn’t died on me yet. Well, anyway, that’s the concept behind it. In order to “force” creating excerpts, I used the the_excerpt tag. This way, even if you don’t specify an excerpt for your post, it automatically creates one by getting the first 120 words in your post.

However, graphics and HTML tags are stripped from these excerpts. That’s why your password-protected text field doesn’t show up on the index page, Nikita ๐Ÿ™‚ Click on the post name link and it’ll show up on the single page view. There is a workaround though, which is basically the same solution for Josie’s question.

When you open up the index.php page, the highlighted tag on the screenshot tells you where the the_excerpt tag is located:


That’s what we need to edit to achieve the effect Josie wants to accomplish: to remove “[…]” from the end of the excerpt and replace it with “continue reading” link.

Once you’ve located the tag, all you need to do is change it to:

Screenshot of the code

You can even create a new style for this link and add a class=”yourstyle” for the html tags within the apostrophes. The WordPress documentation for this template tag discusses this with more detail.

However, unlike the the_excerpt tag that automatically generate “120-word summaries” for your posts, you will have to specify the point at which the excerpt will end. You need to put Screenshot for manually creating an excerpt right after the last word you want to be seen in the excerpt while in the Post editor of the WordPress Admin. That’s actually another reason why I made it to automatically create excerpts (even though I’m stuck with the […] thing at the end of my posts), I’m too lazy to do that on every post. I might even forget to do that ๐Ÿ™‚ Hehe.

Anyway, that’s it. Just play around with these two template tags (just make sure their within the “entrytext” DIV or the styling will screw up). Enjoy!

Let's talk!

Do you need help deciding which website package is best for you? Get a quote below!
For other inquiries, click here to send me a message.