Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get 2 paragraphs from resource content for excerpt
- function fs_resource_excerpt($content) {
- $dom = new DOMDocument();
- $dom->loadHTML(mb_convert_encoding(wpautop($content), 'HTML-ENTITIES', 'UTF-8'));
- $finder = $dom->getElementsByTagName('p');
- $count = 1;
- $newPara = '';
- foreach ($finder as $item ) {
- if ($count <= 2) {
- $newPara .= '<p>' . $item->nodeValue . '</p>';
- }
- $count++;
- }
- return $newPara;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement