Tricxee
Member
Posted 4 months ago #
Hello I was wondering if it was possible to make a excerpt that cuts the post after first image of the post? Without ruining the html tag endings.
All I've gotten to work was with word count or letter count BUT ruins my html tag endings.
# I do not want to use plugins to get this to work.
# The excerpt should allow me to use html tags.
# I am open for the use of wordpress "more tag" but the only downside of this, some says it ruins the html tag endings. IF you know a workaround of this please let me know, such as a fix or hack.
Thanks.
Here is a custom_excerpt() function that I have used in this situation. Not guaranteed to work in every case, but good for me so far.
[code moderated per forum rules - please use the pastebin for any code longer than 10 lines]
Perhaps you can adapt it to look for the first image.
Tricxee
Member
Posted 4 months ago #
Sorry for my late reply.
I'll check it out :) So far I'm just using a custom wordpress "More tag" making every post unique.
Thanks.
Tricxee
Member
Posted 4 months ago #
btw. you gotta post your code on pastebin and repost the link here, thanks.
Yeah, usually the moderators are a little more flexible.
Anyway, here is a link to an article with the code:
http://wordpress.mcdspot.com/2012/01/21/custom-excerpt-to-handle-broken-html/