• Resolved Phil Gyford

    (@philgyford)


    I have Jetpack set to “Add the Subscribe Block at the end of each post”, which works fine.

    But I have a custom template for some images that displays some extra HTML after the main content. Currently the Subscribe Block appears between the main content and this extra HTML. I’d like the Subscribe Block to appear after the extra HTML, but I don’t know how.

    The relevant part of my template is like:

    <?php the_content(); ?>
    <table class="image-meta-fields">
    <!-- more extra html -->

    This results in:

    • Post content (the image)
    • Subscribe Block
    • My extra HTML

    But I’d like it to be:

    • Post content (the image)
    • My extra HTML
    • Subscribe Block

    Any ideas? Thanks.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi there, @philgyford,

    Thanks for reaching out. This is a great question!

    The “Add the Subscribe Block at the end of each post” feature hooks into the post content, which is why it appears before your custom HTML that’s added after the_content() in your template.

    Here’s what you can do:

    1. Disable the automatic insertion by going to Jetpack → Settings → Newsletter → Subscriptions and turning off “Add the Subscribe Block at the end of each post”
    2. Add the shortcode directly in your custom template after your extra HTML using do_shortcode():

    <?php the_content(); ?> <table class="image-meta-fields"> <!-- your extra html --> </table> <?php echo do_shortcode( '[jetpack_subscription_form]' ); ?>

    This gives you complete control over exactly where the subscription form appears in your layout.

    You’ll find more details about the shortcode and its available parameters in our documentation here: Jetpack Newsletter

    I hope this helps! Let me know how it goes 🙂

    Thread Starter Phil Gyford

    (@philgyford)

    Great, thank you, that worked!

    I also had to make a copy of template-parts/content-single.php for my custom theme, so that I could place the shortcake in there too, so it appears at the end of blog posts even though the setting is turned off.

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hey @philgyford,

    Glads it worked! I checked the page you initially linked and it looks good now 🙂

    This thread is now solved. If you have any further questions or need more help, you’re welcome to open another thread here. Cheers!

    • This reply was modified 3 months, 2 weeks ago by Stef (a11n).
Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.