最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to output only blockquotes content from recent posts in a widget?

programmeradmin3浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

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
发布评论

评论列表(0)

  1. 暂无评论