Skip Navigation

[Resolved] Insert views after nth paragraph of post content

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by abrahamL 5 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#1343505
toolset_question.jpg

Tell us what you are trying to do? Try to insert a toolset view (slide) between paragraph. To be exact after 3rd paragraph.

Is there any documentation that you are following? I couldn't find any.

Is there a similar example that we can see? I uploaded a mockup page for the single post page.

What is the link to your site? Still in the idea phase, I want to make sure it's possible first before I give the design idea to a client.

My rough idea is to do it with 3 diff views.

view #1 : limit the content for the first 3 paragraph. Within (<p></p>)
view #2 : slide / feature image / or anything
view #3 : content start from paragraph 4

Thank you.

#1343689

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Abraham

I don't see any way you can do this automatically very easily.

Because the content of a page—what's saved as post_content in wp_posts—is handled in its entirety.

I can output the content of whatever page wherever I like using Views shortcodes, but there's no ready way to output just the first 3 paragraphs of the content, for example.

You can sort of do that with the post excerpt, though that's based on character count or word count, but there's no equivalent to show the rest of the content excluding the initial excerpt.

A View doesn't help, because a View queries the database for posts and iterates over them. So if you were displaying a list of posts, you could insert something after the 3rd post, or after every 3rd post, yes, you can do that.

For your request you would need to write a custom shortcode to output the post content which used regular expressions to extract either the first 3 paragraphs or everything after the first 3 paragraphs, as required.

That's custom work that I can't do for you, I'm afraid.

You can learn more about creating custom shortcodes here: https://developer.wordpress.org/plugins/shortcodes/

Learn and test regular expressions here: hidden link

#1344809

Thank you for pointing me to the right direction Nigel.