Post Snippets WordPress plugin

The relentlessly helpful® blog by John Espirian

16 January 2021
Post Snippets WordPress plugin

How to make your WordPress website more consistent by reusing repeatable blocks of content.

If there’s one thing that wastes our time more than anything else, it’s repeating ourselves when we write our content.

Whether it’s looking up that list of links you wrote 5 blogs ago or including a set of social media buttons or other logos, it can be frustrating to spend time doing the same thing over and over again.

Well, I have a solution for you: Post Snippets.

What is Post Snippets?

Post Snippets is a free plugin for WordPress that lets you create reusable blocks of text and other code (“snippets”) that you can drop in anywhere on your WordPress pages and posts.

You can add these snippets to your headers, footers and other parts of your WordPress template.

Apart from saving you time, Post Snippets helps you get rid of inconsistency, like those typos that appear when you’ve written something for the umpeenth time. And it produces WordPress content that’s lean and clean to look at.

Post Snippets saves blocks of code that can reused throughout your site. It works best for people who use the Text view of the WordPress editor.

But even if you prefer the Visual view when writing and editing your pages, you can still use Post Snippets – you’ll just need to switch to Text view to copy the parts of the page that you want to reuse and then turn them into snippets.

Each snippet comes with a set of options:

  • Description: an explanatory title to help you remember what the snippet does. Your readers won’t see this.
  • Variables: you can enhance your snippets with variables that you define at the point you insert them in your pages. For example, variables could be used for an Amazon Affiliate link, where most of the code is the same but the only things that differ are the product name and product ID. Set up those two items as variables and you’ll be prompted to enter them each time you insert the snippet. This is a perfect way to add flexibility by going beyond the use static code.
  • Shortcode: when ticked, this option allows you to insert snippets that have a “live” link back to the stored code. This means that if and when the snippet code changes, those changes are automatically applied to all places where the snippet has been used.
  • PHP code: when ticked, this option allows you to insert PHP code into your snippets. An example might be to include the code echo Date('Y');, which displays the current year (a perfect way to avoid having to update your copyright notice each year!).
  • wptexturize: when ticked, this option automatically handles some text-formatting tasks for you. For example, it changes normal quotes into smart quotes.

Here’s what a snippet looks like:

Snippet sample
Snippet sample

This is all good in theory, but how about some practical examples of how to use Post Snippets. Check out the following for inspiration.


The simplest use of Post Snippets is to store pricing information. I do this for my various writing and LinkedIn services.

Pricing info

This means that I can put, for example, [price-blog] into my pages and posts and be sure that the latest price for my blog writing is always shown automatically.

Here’s this in action. Dead simple:

Pricing example

Blog sign-off.

If you sign off your blogs using a small number of regular endings, you can place this text into a snippet.

Then, when you write your post, you can end the content with one of these snippets, safe in the knowledge that it will give your readers the right call to action (CTA) that you want.

I usually end my blog posts by encouraging readers to keep in touch by signing up for my mailing list, but there are times when it makes sense to use a different sign-off. For example, an article about LinkedIn might end with a custom image that prompts readers to connect with me on that social platform.

The only limits here are your imagination, and having these prewritten “conclusion” snippets for your blog means you’ll never be stuck for a good way to bring your content to a close.

Row of social buttons and client logos.

If you link out to your social media profiles, placing the code for the buttons/images into a snippet will mean you can reuse it in multiple places.

For example, links to social media could appear discreetly in your footer but also more prominently on your contact page, email subscription page or in relevant blog posts.

You could also use the same approach to create a snippet of all the logos of clients you’ve worked for. These could then sit in your footer, on your testimonials page and anywhere else where you want to talk about your professional experience.

In general, Post Snippets works well for any regular set of images that may need to be repeated across your site.

For example, here are some social buttons included on my contact page:

Social buttons
Social buttons

And here is the snippet code, created using the Foundation icon font:

Social buttons snippet
Social buttons snippet

Click to Tweet.

Click to Tweet is a free service that lets you create links that point to readymade tweets. You can place these on your site to make it easy for your blog readers to share interesting snippets of content on Twitter.

A Click to Tweet box on your website might look like this:

Click to Tweet sample
Click to Tweet sample

The code inside the WordPress editor might look like this:

Click to Tweet snippet inserted in post
Click to Tweet snippet inserted in post

This snippet includes variables. That’s useful here because Click to Tweet code takes a regular format and the only things that change are the last part of the web address and the snippet of text you want to share.

Here’s a snippet for Click to Tweet:

Click to Tweet snippet with variables
Click to Tweet snippet with variables

Note that the variables are inserted using curly braces: {text} and {ctt}.

This approach means that you have much better control over the styling of your Click to Tweet content.

If you change the CSS that controls this content, all of your Click to Tweet items will automatically update because all of the snippets are using the same code. If you’d placed each Click to Tweet item in manually, you’d be faced with having to update each of them individually.

Embedded video.

If you want to embed video from YouTube, Vimeo or other video-sharing sites, you’ll need to generate the code and paste it in to your site.

You can keep your code lean by creating a snippet for such videos and using a variable for the video’s identifier string.

Video snippet with variable
Video snippet with variable

For some of my videos, I include some extra code beneath the video that points visitors to subscribe to my YouTube channel.

Video snippet with extra code to add a subscription prompt
Video snippet with extra code to add a subscription prompt

Amazon Affiliate links.

If you share links to products on Amazon, it’s best to do so while including your own Amazon Associates identifier, so that you earn affiliate income for any purchases made via clicks of links on your site.

The format of your affiliate link will always be the same. All you need to do is create a couple of variables for the product name and the product identifier.

Amazon snippet
Amazon snippet

Placing a link in a post then becomes a simple case of calling the snippet and entering the product code and the title:

Amazon example
Amazon example

“Back to top” links.

It’s good to break up the walls of text in your blogs by using subheaders to create sections of content. You can start longer post with a list of links that jump readers straight down to the section of interest.

And you can include further links in each of those sections that take readers back to the top of the article.

These “back to top” links should all have a consistent look and feel, and should be easy to change if and when you update your site’s visuals.

Jump to the top snippet
Jump to the top snippet

Here’s an example. It includes an emoji to indicate that the link will move the reader back up the page, and there’s some explanatory text on the link to confirm that this is what will happen when it’s clicked.

Jump to the top
Jump to the top

Giving a CSS class to the paragraph means that we can control the size, position and colour of the link. As usual, any change to the snippet will automatically apply to all instances of this “back to top” link.

Embedded site search.

I can never remember the code used to generate the search field and search button on my site, so I’ve stored it inside a snippet. That means I can add search to my footer, my homepage and anywhere else I choose.

Search field
Search field

And instead of seeing all that techie code when editing my pages, the snippet replaces it with a single word in brackets – nice and simple. My snippet is called [search].

Ugly search form code
Ugly search form code

Imagine you write a multipart series on your site and you want each part to link to the other parts.

Let’s say there are 10 parts in the series and so far you’ve written 5 of the parts.

In each of the parts, you’d need to add a list of links pointing to the other parts. Then, as each new part is published, you’d need to go back to the previous parts and update each of the lists to include a link to the new part.

Who has time for that? It would be much easier to store the list in one place and then tell each part of the series to display whatever the latest version of the list is.

This is where Post Snippets provides exactly the functionality we need.

Sample multipart link list snippet
Sample multipart link list snippet

This snippet contains the list we want to include in each part of the series.

We set it up with the shortcode box ticked so that each part knows that it needs to display the up-to-date information in the snippet. If the snippet changes, the content in each part automatically changes.

If we didn’t tick this box, the snippet would just place its current contents into the article. If the snippet were later updated, that wouldn’t also update the contents of the article.

Sample multipart link list on the web
Sample multipart link list on the web

When to leave the shortcode box ticked.

To maintain a “live” connection between a snippet and the pages on which it appears, make sure the shortcode box ticked.

If you want to use a snippet to paste a plain block of text that doesn’t need to be updated centrally, you can leave the shortcode box unticked.

Here’s an example of when that might be useful. Say that you want a quick way to insert two equal-width columns on a page. The content of the columns could be anything but you know that the basic framework is always going to be the same – you just need a quick way of pasting in the relevant HTML.

In this case, it’s sensible to place the code for the columns into a snippet and leaving the shortcode box unticked.

Such examples are rare for me, so in almost all cases I leave the shortcode box ticked.

Let’s wrap up.

Post Snippets is all about saving you time and getting rid of the boring, repetitive parts of writing content in WordPress. The examples above show lots of useful ways to make your pages and posts leaner and more consistent.

Look at your own WordPress code and see which bits you’re repeating over and over again. Those are great opportunities to save time by creating a snippet.

How about making Post Snippets for your calls to action or email signup boxes, for example? The only limit is your imagination!

All of the above features are available in the free version of the Post Snippets WordPress plugin.

For even greater power, there’s now a premium version of Post Snippets. If you want to take your WordPress content to next level, give it a try.

Get Post Snippets.

This is the only WordPress plugin I pay for. It’s that useful!


Get your plugin


Be part of Espresso+

The community for freelancers & small business owners.

119 recommendations
for John

John Espirian

I’m the relentlessly helpful®️ LinkedIn nerd and author of Content DNA

I teach business owners how to be noticed, remembered and preferred.

Espresso+ is a safe space to learn how to ethically promote your business online and get better results on LinkedIn.

Follow me on

Share on
social media