@tangobango
Apologies for the delayed response.
I’m still unclear on how you wish to form the subscription with content filtration.
You may simply display the box in the widgets section of your page.
Do let me know your views on the same.
@prathameshp
Thanks for the reply.
I don’t want the subscription form in a widget area, but below the main content on each post, appended to the body of the post.
If I use the approach I indicated in my first question, I can add any text/html I want to the bottom of the content with $content .= $new_content. But I can’t get the subscription form to show up correctly. The problem likely is related to the output of the es_subbox function.
It’s really baffling that the filtering makes it show up twice in the wrong places. That shows, at least, that the html for the form is being created.
Does this make sense?
In case someone else has this problem. here’s what to do:
In your function that creates the filter, use
do_shortcode( ' [email-subscribers namefield="NO" desc="" group="Public"] ' )
rather than
es_subbox($namefield = "YES", $desc = "", $group = "Public")
so you end up with a function like this:
function obia_output_email_subscribers_after_content( $content ) {
if(( is_single() || is_page('read-from-the-beginning')) && is_main_query() ) {
$output = '<div class="email-subscription-box">';
$output .= '<p class="email-subscription-box-title">Like What You Are Reading?</p>';
$output .= '<p class="email-subscription-box-copy">Join us and receive new posts by email.</p>';
$output .= do_shortcode( ' [email-subscribers namefield="NO" desc="" group="Public"] ' );
$output .= "<p class='email-subscription-box-disclaimer'>Unsubscribe anytime. No spam guarantee. We don't share our list.";
$output .= '</div>';
$content .= $output;
}
return $content;
}
add_filter( 'the_content', 'obia_output_email_subscribers_after_content' );