2. Create a new snippet and paste the following code:
function lazybit_thankyou_content($content) { $fullcontent = $content; if ( is_single() ) { $after_content = '<div class="user_thank">Thank you for reading so far, please share and scroll down to see if there are more article you can be interested in, please donate</div>'; $fullcontent = $content.$after_content; } return $fullcontent; } add_filter('the_content', 'lazybit_thankyou_content');
Done. This code will add your content after the main post content in a single post.
I don't know how to insert above html content in your code, everytime I try it breaks the snippet.
So far the best way I found is to convert the above html content to a shortcode using Shortcoder plugin and then insert the shortcode in the code you provided me this way:
Your snippet is working great. Now I need that after-content to not being generated on one or more specific posts. Is there a way to add a kind of exclusion-list to your snippet?
Hi dev,
I would like to automatically add to ALL past and future posts an html snippet in the end. I mean something like:
"Thank you for reading so far, please share and scroll down to see if there are more article you can be interested in, please donate" etc.
What's the best way to do that?
PS I setup this ticket as public because maybe can be interesting for someone else too.
Hi,
Please follow the instruction:
1. Install the Code Snippet plugin,
2. Create a new snippet and paste the following code:
Done. This code will add your content after the main post content in a single post.Best Regards,
PenciDesign.
It works great, thank you!
... But I can't make it working with a more complex content. Example:
------------
Thank you for reading so far, now you have 2 options to donate:
See you!
------------
I don't know how to insert above html content in your code, everytime I try it breaks the snippet.
So far the best way I found is to convert the above html content to a shortcode using Shortcoder plugin and then insert the shortcode in the code you provided me this way:
It works, but I would like to not using any external plugin. Any help?
Hi,
You MUST write your content in HTML format, for example:
You can go to https://html-online.com/editor/ and replace your content here.Best Regards,
PenciDesign.
Great, now I can do it this way :)
Thank you for your patience, you rock!
Your snippet is working great. Now I need that after-content to not being generated on one or more specific posts. Is there a way to add a kind of exclusion-list to your snippet?
Hi,
Please modify the code like this:
Replace 1681,1673 with the post ID list you want to exclude, separate by a comma.
If you don't know how to find the post ID, please read the document here.
Regards,
PenciDesign.
It works perfect, thank you.