Insert template-part inside the content

I want to display an image/banner with link, inside the content of the posts of my blog. Neither at the beginning, nor at the end. It should appear somewhere inside the content of the post. I don’t want to use a shortcode, I need the banner to be automatically inserted to all posts.

First I created a template part with the banner, which I can easily call using:

<?php get_template_part( ‘template-parts/banner’ ); ?>

I though that a good rule, would be to insert the banner after say, the 3rd paragraph. Or after 300 words. Or after 900 characters. Or something like that. If the post is too short I don’t need the template part to be displayed.

Can anyone please help me achieve this?

Read more here:: Insert template-part inside the content

Leave a Reply

Your email address will not be published. Required fields are marked *