Jump to content

Adding a button to the top of all blog posts

Recommended Posts

  • Replies 3
  • Views 3.6k
  • Created
  • Last Reply

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. 
I remember when it was all wild prairies round these here parts. 🐃🤠
Advice I give on here is free, though I may sometimes post an affiliate link or promote something I've written.
That reminds me.. ..you might want to check out my
Squarespace template finder or have a look at my other Squarespace tips
Speaking of tips, 💲I've got a tip jar that you're welcome 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  

 

Link to comment

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-->

Link to comment

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. 
I remember when it was all wild prairies round these here parts. 🐃🤠
Advice I give on here is free, though I may sometimes post an affiliate link or promote something I've written.
That reminds me.. ..you might want to check out my
Squarespace template finder or have a look at my other Squarespace tips
Speaking of tips, 💲I've got a tip jar that you're welcome 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  

 

Link to comment

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.