The Filipino Web Designer

A half-geek, half-artist’s creatively nerdy journal on design and blogging

11
Mar 2006
The entry excerpt
Posted in Theme: Dapit Hapon, WordPress by Gail at 9:44 pm | 7 Comments »

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:

the_excerpt

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!


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

7 Responses:

Josie said:

Thank you again Gail.

I think I will probably keeps things the way they are.I’m too lazy to do the More thing as well.I assumed there was another way to just turn the [...] into a link.
:)

You’re welcome! :) –Gail


Kim said:

I love, love, LOVE this theme, it is exactly what I’ve been looking for! Thank you so much for the time you have put into it, it is fantastic!!!


nikita said:

Ahhh, thank you so much! I am definitely going to use the update when I change my blog theme next month! BTW, I am fil-am and it’s great to be able to use a theme that is definitely filipino-themed!


Josie said:

I’m so mad that I am seeing this theme everywhere now.I am selfish and do not wish to share… lol.


Robin said:

Is there also a way to load the full text messages on the homepage? SO to delete the excerpt?


rik said:

thanks for giving justice to my murmurs re:why picture/image doesn’t display in the frontpage. anyway, keep up the good work!


Mikko said:

When I started theming WordPress, I had problems on differentiating the_content and the_excerpt. But later on, I’ve come to realize their differences. I prefer the_content now rather than the excerpt + the more link.

I hate it when HTML tags are stripped. Blockquotes are not emphasized, as well as other formatting tags.


Leave a Reply