Forum

You must be logged in to post Login Register

Search Forums:


 






need help with a shortcode to trim the sermon description

How do I?
UserPost

12:24 am
9 March, 2010


anointed

Guru

posts 57

Post edited 12:25 am – 9 March, 2010 by anointed


I've been struggling for a couple of days now to get a shortcode for the sermon description set where I can 'trim' the sermon description shortcode.

example:
http://shawngaffney.anointed.n…..t/sermons/

It looks really stupid having the entire sermon text displayed on the archive page. I would much rather have a sermon description much like an excerpt for wordpress.

I have written many 'trim' excerpt functions before for normal wordpress excerpts, but just can't get the hang of doing it with sermon-browser.

Would someone be so kind as to lend a hand?

also:
I've noticed that every page on my test sites loads very fast, except anything doing with sermon-browser. There are only 2 sermons on this dev site, and yet sometimes the load time is so long that the page does not load properly.

Is there any easy way to test to see if there is a stuck db loop somewhere?

thanks

4:00 am
12 March, 2010


anointed

Guru

posts 57

Post edited 4:01 am – 12 March, 2010 by anointed


bumping this up in hopes that someone can lend a hand.

Many of the sermons have anywhere from 2-10 pages of notes with them, and as it's displaying the entire description, it's starting to look really stupid.

@Mark — do you have a few mins to code up a trimming function for this?

(I know wp3.0 is going to radically change things, but unfortunately for me I can't wait for 3.0 on the current project. I tried using 3.0alpha but it's truly alpha still and nowhere near production ready)

btw
tracked down the slowness issues. I had way to much loading into the archive template via js. Was not an issue with sb

8:39 pm
18 March, 2010


anointed

Guru

posts 57

trying one more time to see if I can get some help with this.

Here is an example of the code I use to trim the_content on my homepage. I am looking for something similar to trim the sermon description.

/*this function allows for the auto-creation of post excerpts*/
function truncate_post($amount,$quote_after=false) {
$truncate = get_the_content();
$truncate = apply_filters('the_content', $truncate);
$truncate = preg_replace('@<script[^>]*?>.*?</script>@si', ", $truncate);
$truncate = preg_replace('@<style[^>]*?>.*?</style>@si', ", $truncate);
$truncate = strip_tags($truncate);
$truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ' '));
echo $truncate;
echo "…";
if ($quote_after) echo('"');
}

I then simply call it in my template like:

<?php truncate_post(305); ?>

please help


About the 4:14 evangelical christian theology blog forum

Most Users Ever Online:

19


Forum Stats:

Groups: 1

Forums: 6

Topics: 544

Posts: 2106




Popularity: 37% [?]