[wordpress] How to centrally manage the common post part in multiple posts and automatically insert it

Have you ever written a WordPress post and wished you could centrally manage the common post part in multiple posts?
(For example, if it is Google Adsense code or if you want to embed a small advertorial post in multiple posts)

If centralized management is not possible, all articles containing the common article will have to be corrected, such as when a common part is corrected or an article is replaced, which is very inefficient and labor-intensive.

For such people, here we will introduce a method to centrally manage the common article part and automatically insert the common article at the specified position of the specified article.

Contents

How to centrally manage common posts and automatically insert them into multiple posts

Now, We will explain how to centrally manage common posts and automatically insert them into multiple posts.

Realization method:
As a realization method, use the Shortcode function of WordPress.
There are two ways to use the Shortcode function, either by editing the PHP file or using a plugin, but this time I will show you how to do it using a plugin.

Shortcode allows you to call a code(or part of post) by specifying a simple character string that has been set in advance in a bracket ([]) that is enclosed in parentheses.

This time, use this function to set the common post part in Shortcode.
After that, just write a simple character string enclosed in [] in the “position where you want to insert the post you want to insert” for the common post, and the common post will be inserted there.

Plugin to use:
Use a plugin called Shortcoder.

Install Shortcoder

Now, install Shortcoder to use Shortcode.

  1. Click “Add New” from the wordpress plugin screen.
  2. Enter “Shortcoder” in the search window and install the following plug-in.

3. After installation, enable “Shortcoder” on the plugin screen.
4. That’s it for installing and activating the plugin.

Short code setting

Next is the Short code setting.

Go to “Shortcoder”-> “Create Shortcode” on the WordPress screen.

The following screen will appear.

For A,
Set the character string to be used when calling the common post.

For B,
Write the code of the post that will be the common post (in this example, it is the code of Google Adsence).
The content described here will be called later.

You can choose from three types of description here: “text editor”, “visual editor”, and “code editor”.
In the latest WordPress, usually it is used the block editor, so if you are accustomed to that, once you write the post that will be the common post part in the block editor on the posted post, then the three points on the upper right of the screen Select “Options”-> “Code Editor” to display the code of the common post.
If you copy the code of the post displayed there and paste it in the description field of B here, you can set the content described in the block editor as it is as a common post.

For C,
After completing the settings for A and B, press “Publish” in C to save the common post.
If you want to replace the common post or modify a part later, after modifying the description of B again, the “Update” button will appear in C, so if you press update, the update of the common post will be completed.

For D,
It will be the character string set here when calling the common post.
Here, you can copy this character string and paste it in the post you want to insert, or if you are using the block editor, select “+” → “Shortcoder” in the block editor to select the registered Shortcode. A list will appear, so you can choose from it.

Automatic insertion of common posts

Finally, insert a common post.

Open the post you want to insert the common post set up so far from the posting screen, and move it to the position you want to insert further.

If you can move to the position you want to insert, go to “+” → “Shortcoder” in the block editor and a screen like the image below will be displayed.
On this screen, if you enter the shortcode of the common post you set earlier directly in the input list or select “Select shortcode”, the registered Shortcode list will be displayed, so select the Shortcode you want to insert from there. so you can also insert it.

So, as an example, let’s try the automatic insertion of the common post(code) below using the Short code of the Google adsense ad code created so far.

↓↓↓Insert Google Adsense ads with short code START↓↓↓

↑↑↑Insert Google Adsense ads with short code END↑↑↑

In this example, the Google Adsence ad code is converted to short code and displayed, but as mentioned above, it is also possible to convert part of the post such as paragraphs to short code and insert a common post.

In this way, by centrally managing posts that are common parts, it becomes possible to correct or replace common posts inserted in multiple posts in one place, which leads to great work efficiency. So let’s consider introducing it.