If you ever find yourself adding the same text or code to your WordPress posts on a regular basis, and you want a way to make that process more efficient, then today’s article is just for you.
Depending on your site, you might have stock content that you often add to your posts and pages. This could include pieces of text, such as an introduction, or a disclaimer notice. Perhaps its images, buttons, links, or certain formatting you often apply to text. It might even be a sign up form for your newsletter.
Whatever the content is that you find yourself repeating on a regular basis, there is a great feature of WordPress which can save you a lot of time and effort, while also helping you to become more productive by creating reusable blocks of content. In this post you will learn how to create those reusable blocks of content using a handy free plugin.
How to Create Reusable Blocks of Content
Before we get to the tool that can help you create a piece of content once, and then add it to multiple posts and pages at the touch of a button, let’s just take a quick look at the technology behind this great timesaver.
The Power of Shortcodes
Hopefully you are aware of the power of shortcodes in WordPress, and are familiar with plugins like Symple Shortcodes. If you haven’t yet been introduced to the wonders of shortcodes, they are essentially words in square brackets, or short codes, which when added to a post, are replaced with a larger piece of text or code when the post is published.
What are WordPress Shortcodes Used For?
This text or code could be anything of your choosing, from a sentence or link that you reuse often in your posts, or some formatting you would like to apply to a piece of text, or even images, buttons, videos, or anything that can be displayed in a WordPress post.
Perhaps the best thing about shortcodes is that if you then edit the content that the shortcode is inserting into your posts, every instance of that shortcode on your site will now display the updated content. This can save you countless hours, preventing you from going through all your existing content and having to make changes to each post individually.
While there are many plugins that add a whole library of pre-built shortcodes to your WordPress site, wouldn’t it be great if there was a way to easily create your own shortcodes that contain the content that is unique to your needs?
Enter Global Content Blocks
Global Content Blocks is a tried and tested free plugin that makes it very easy to create your own pieces of reusable content which can be inserted into your posts, pages, widgets, or theme files, simply by entering a shortcode.
How to Create Your First Shortcode
Once you’ve installed the plugin on your WordPress site by searching for Global Content Blocks from the Add New Plugin page, there will be a new item added to the Settings menu titled Global Content Blocks.
From the Global Content Blocks page within your site, click on the Add New Content Block to create your first piece of reusable content. In this example I will create a sentence that I want to add to the end of some of the posts I write that encourages readers to leave a comment.
In the first four fields enter the text to describe your content block and choose the type of content you will be adding to the block from the available options:
- Opt-in Form
- PHP Code
As you can see you can enter pretty much any type of content into these reusable blocks, you can even enter the shortcodes for other reusable blocks if you are feeling adventurous. Once you’ve setup the content block, it’s time to create the content.
As you can see you conveniently get access to the WordPress visual editor so you can format the content, or even add an image that will all be inserted into your posts and pages. Once you are happy with your content you can save it. However, don’t worry about getting it perfect just yet as you can go back and edit any of your content blocks at a later date.
After saving the content block, it will be added to the list of other blocks you’ve created. These blocks can then be edited or deleted from your site if necessary. You will also notice that each block has two shortcodes. In my example they are:
- [ contentblock id=1 ]
- [ contentblock id=comment-text ]
Both shortcodes are linked to the same piece of content, and when adding a shortcode to your posts, the content in the block will be displayed when the post is published.
Inserting the Content Blocks
So although you can type in the shortcodes if you know the ID, this plugin includes another handy feature. If you create a new post or open an existing one for editing, you will notice there is a new button on the post editor.
By clicking this icon you can quickly choose the desired content block from the dropdown list and add the content to the post.
When adding the content block to your post, you have two options:
- Insert the shortcode
- Insert full content
By default the plugin will add the shortcode, and when the post is published or previewed, the content in the block will be displayed. The second option – insert full content – will insert the content from the block straight into your post editor without using a shortcode. This is useful if you want to make a one-time edit to the content in the block, before using it in your post.
The benefit of the first option, and inserting a shortcode, is that should you need to make changes to that content block in the future, you can edit the content block once, and then each time that shortcode has been used, that content will be updated to reflect the changes you’ve made. This will save you editing all the individual pages that contain that piece of content, and making the changes one by one. By previewing the post, you can see the contents of the content block displayed in your post.
Hopefully you can see many situations where this plugin can save you a lot of time and effort. As almost any content can be added to a content block, and the blocks can be added to almost any part of your site – including widgets and theme templates – you can get really creative with this powerful feature of WordPress. To view some advanced usage examples visit the plugin documentation page.
What content can turn into a reusable content block to save yourself time and effort?