WordPress quick tip: has excerpt?
The autogenerated excerpts in WordPress can cause quite a mess, especially when using markdown or textile syntax for formatting. It automatically takes the first 80 or so characters, then inserts a […] and crops the rest. There are plenty of plugins that generates better excerpts, but most of the time all I need is some simple logic, which goes a little something like this:
If a written article excerpt is present, then show it, otherwise show full article content.
which in PHP/WP terms translates into the following piece of code:
<?php
if (empty($post->post_excerpt)) {
the_content();
}else {
the_excerpt();
?>
<p><a href="<?php the_permalink() ?>" class="more">Continued...</a></p>
<?
}
?>
So there; nice and simple. Or at least simple.
5 comments so far. Go ahead, write something
You can follow any responses to this entry through the RSS feed
Hej Bjørn
JEg er gode venner med Mathias Willerup og han har ledt mig tildit site. Jeg har nu fjernet en excerpt på en kort blog, som jeg hellere ville poste fuldt ud. Desværre viser den hverken links “a href’s” eller billeder i feed/ forsiden. Man skal stadig klikke for at se det hele.
Er der em løsning på det?
-Thomas
#1 thomas 17 Mar 06
Hmm, har du et eksempel på hvor det går galt?
#2 bjorn 01 Apr 06
Hi!
I would like extend my SQL experience. I red really many SQL resources and would like to read more about SQL for my occupation as oracle database manager.
What can you recommend?
Thanks, Werutz
#3 werutzb 08 Oct 08
Test message Sorry me noob…
#4 ToloPloth 19 Oct 08
There was this guy see. He wasn’t very bright and he reached his adult life without ever having learned “the facts”. Somehow, it gets to be his wedding day. While he is walking down the isle, his father tugs his sleeve and says,
“Son, when you get to the hotel room…Call me”
Hours later he gets to the hotel room with his beautiful blushing bride and he calls his father,
“Dad, we are the hotel, what do I do?”
“O.K. Son, listen up, take off your clothes and get in the bed, then she should take off her clothes and get in the bed, if not help her. Then either way, ah, call me”
A few moments later…
“Dad we took off our clothes and we are in the bed, what do I do?”
O.K. Son, listen up. Move real close to her and she should move real close to you, and then… Ah, call me.”
A few moments later…
“DAD! WE TOOK OFF OUR CLOTHES, GOT IN THE BED AND MOVED REAL CLOSE, WHAT DO I DO???”
“O.K. Son, Listen up, this is the most important part. Stick the long part of your body into the place where she goes to the bathroom.”
A few moments later…
“Dad, I’ve got my foot in the toilet, what do I do?”
#5 hogkehele 23 Oct 08
Type here: