Manipulating Excerpts in Wordpress

February 8, 2009

in New Media, The Nitty Gritty, WordPress

Oftentimes in working with WordPress I find that I don’t want things to be as automatic as they are by default. Or, more precisely, I want things to be automatic in a very custom way to fit my theme and design.

Excerpts have long annoyed me, but now I’ve found Advanced Excerpt by Bas van Doren.

If you’re running a site that uses a magazine-style grid layout I’ve found this plug-in to be especially useful.  I’m using Gazette Edition by Woo Themes, but I’ve modified it to make the pictures on the front page run the entire width of the previes boxes for each post.  But, when I did this I found that those posts without photos would be much shorter than those with photos and consequently look very silly.  I solved this with the Advanced Excerpt plugin-in.

After uploading and activating the plugin, the fix is fairly easy.  By creating an if/else statement in PHP, I was able to call up two different excerpt lengths.  If there is a photo, the excerpt is only 20 words.  But, if there isn’t a photo, the excerpt will be 100 words, which just about perfectly matches a post with a photo and 20 words of excerpt.

The calls look like this:

<?php echo strip_tags(the_advanced_excerpt(‘length=20&use_words=1&no_custom=1&ellipsis=%26hellip;&exclude_tags=img,p,strong,font’), ‘<a><strong>’); ?>

<?php echo strip_tags(the_advanced_excerpt(‘length=100&use_words=1&no_custom=1&ellipsis=%26hellip;&exclude_tags=img,p,strong,font’), ‘<a><strong>’); ?>

Both are part of larger statments, but you get the idea.  On my theme specifically I found that I had to repeat much of the code.  In my case this looked like this:

If photo, then get the photo, the date, and a short excerpt.

If no photo, the get the date, and get a long excerpt.

In your specific case you may have to repeat other things like calling the author name or the title.

If you have questions about the plug-in, feel free to contact me or its author.

Share Share    Print Print    Email Email

  • vancontracthire1
    Word press is always existing to work with
  • vanleasing
    With all of these advantages to van leasing, it’s important to note that there are some disadvantages.
    http://www.vansales.com
  • It's great to see some unique content and a good quality blog for once, actually I would be very interested in doing a link exchange with you.
  • There pretty considerable reference material on the WordPress Extend site that should tell you what calls to be making to pull up the right excerpt.
  • Hi. I am trying to use Advanced Excerpt to add embedded video to my excerpts so that the video will show on my homepage. I don't seem to be able to locate the code that addresses this. Can you?

    Many thanks.
  • How successful is this plugin. I have used many of them before in my WP but never the less they were good for nothing. As soon as i install the plugins i get some erorr in running of my WP.
  • It's very, very good. I've had excellent luck with it on OpenMarket.org and GlobalWarming.org
blog comments powered by Disqus

Previous post:

Next post: