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!
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!
Share Improve this question edited Jan 18, 2020 at 16:41 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Jan 17, 2020 at 13:01 KnottKnott 4742 gold badges7 silver badges27 bronze badges 1- I found the solution to my question here: stackoverflow/questions/30179423/… – Knott Commented Jan 17, 2020 at 14:58
1 Answer
Reset to default 0You can use PHP Simple HTML DOM Parser https://simplehtmldom.sourceforge.io/
$html = str_get_html(the_content());
$blockquote = $html->find('blockquote', 0);
echo $blockquote