Wednesday, May 20, 2009

wordpress: the_excerpt function vs the_content function

As I was trying to fiddle with the_content and the_excerpt functions in wordpress I was confused with the use of the two, here is a page that deals more on the excerpts vs content functions; http://codex.wordpress.org/Template_Tags/the_excerpt.

The difference between the two is that the_excerpt does not have any parameters at all, whilst the_content function has three:
<?php the_content( $more_link_text , $strip_teaser, $more_file ); ?>
the more link is pretty much straightforward again, but here something above that I have not really grasped yet, by default the $more_file goes to the default file, but I've played around with it like this <?php the_content('more...',TRUE,'blam'); ?> it didn't do anything.

Another thing is if you change the TRUE value to FALSE and you still have a value for the first parameter, you would still have a more link, it seems that once you have a value for the first parameter Wordpress by defaults the post to have a more link. But you need to have inserted the more button in wordpress or insert this <!--more-->

For the_excerpt function if you have not added an excerpt in the edit post page WordPress automatically displays all of the text up to the 55th character limit, but if you explicitly added one it will display that. Unlike the_content you need to add a read more like this:
<a class="more-link" href="<?php the_permalink() ?>" title="Read More <?php the_title(); ?>"><span>Read More...</span></a>
Personally I would rather use the_content function. Now to my next post I think I should create an excerpts section.

No comments:

Post a Comment