Hi everyone!
I am trying to cut the_content after the first paragraph (e.g. after </p>) but I've had no luck for several hours and searching for this difficult so I'm turning to you guys.
I realize I will have to use some form you string cut (e.g. strstr() < but this one only allows me to cut out everything before </p> unless I run PHP6 which is not possible)..
So, what I want is something that cuts like this.
The content is: <p> Hi everyone! </p> <p> I don't want this to print </p>
And I want this to print: <p> Hi everyone! </p>
I hope this makes sense.
Kind Regards,
Jan-Erik
fitztrev
Member
Posted 4 years ago #
explode maybe? This is quick and gets the job done.
<?php
$blah = exlode( '</p>', get_the_content(), 2 )
echo $blah[0] . '</p>';
?>
Thanks a bunch, works like a charm! :)
I have another question though, is there anyway to strip graphics from get_the_content (e.g. so no images are printed)?
Thanks,
Jan-Erik
fitztrev
Member
Posted 4 years ago #
Yes, you can use strip_tags().
Hi there.
To continue evodex first question - is there a way to only show the first X words of a post (in the loop, in the home page) ?
what php code might do that ?
(since none of the plugins that offer that work in WP 2.6.5)
Thanks