Jump to content

Adding a button to the top of all blog posts

Recommended Posts

Posted

Hi I was wondering if there was a way to add a button that will show at the top of all blogs that are live. It would essentially be a subscribe to our mailing list button that'll ideally be above the blog itself.

Thank you in advance

  • Replies 3
  • Views 3.8k
  • Created
  • Last Reply
Posted

Yes you could use custom scripting to insert a button at the top of blog posts.

Something like:


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

<script>
$(document).ready(function () { 
  $("[YourbuttonHTML]").insertBefore($("body.view-item article > h1 "));
});
</script>

You could also insert the button in the page footer and hide it using css. Then you could use a variation of the code above to move the button from the footer to above a blog post header.

I'm Colin Irwin aka silvabokis.  I've been a Squarespace designer & developer since 2013. 
You might want to check out my
Squarespace Template Finder or read my Squarespace tips
Speaking of tips, 💲I've got a tip jar. Feel free to throw a few quid into if you think I've helped you. 

If you're looking for a Squarespace developer Book a chat or Drop me a line - first meeting is always free  

 

Posted

Thanks for your help @silvabokis

How would you go about adding a mailchimp signup form to show up before each blog? The code is below.


<!-- Begin MailChimp Signup Form -->

<link href="//mailchimp.css" rel="stylesheet" type="text/css">
<style type="text/css">
 #mc_embed_signup {
   background:#fff; 
   clear:left; 
   font:14px Open Sans, Helvetica,Arial,sans-serif;
   border-top: 1px solid #eeeeee; 
 }
</style>
<div id="mc_embed_signup">
 <form>
   form details - too long to post.
 </form>
</div>

<!--End mc_embed_signup-->

Posted

I would:

  • drop the stylesheet information into the blog's code injection point
  • insert the form code into the site footer in a code block, wrapped with a div called something like < div id="chimpFormWrapper" > [form code] < /div >
  • set #footer #chimpFormWrapper to display:none
  • write a script (similar to the one above) that, on blog posts, moves div#chimpFormWrapper above body.view-item article
  • add any additional css styling needed to make #chimpFormWrapper and its contents look neat and tidy.

The above looks like a lot but it's probably 30 to 45 minutes work to build & test.

I'm Colin Irwin aka silvabokis.  I've been a Squarespace designer & developer since 2013. 
You might want to check out my
Squarespace Template Finder or read my Squarespace tips
Speaking of tips, 💲I've got a tip jar. Feel free to throw a few quid into if you think I've helped you. 

If you're looking for a Squarespace developer Book a chat or Drop me a line - first meeting is always free  

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.