I created a simple widget that displays recent post titles. How can I only display the content that is between < blockquote >< /blockquote > from recent posts?

For example, all my posts have a blockquote html tag like this:

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

< blockquote >Blockquote content< /blockquote >

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."

Basically I need to display recent posts like this:

Recent posts widget title

Post title 1

Blockquote content from post

Post title 2

Blockquote content from post

Post title 3

Blockquote content from post

Thank you!


1 Answer 1


You can use PHP Simple HTML DOM Parser https://simplehtmldom.sourceforge.io/

$html = str_get_html(the_content());
$blockquote = $html->find('blockquote', 0);
echo $blockquote

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.