Global Content Blocks: Embedding HTML, Iframes, PHP, or Scripts into WordPress

UPDATE: THIS PLUGIN REFERRED TO BELOW HAS BEEN REMOVED FROM THE WORDPRESS DIRECTORY. IT ISN'T COMPATIBLE WITH LATEST VERSIONS OF PHP AND SHOULDN'T BE USED

code sphereI have always been a huge advocate for WordPress. Today I want to add another WordPress Tutorial by discussing issues with embedding advanced code into WordPress pages and posts. Have you ever copied a string of code from another site or tool and tried to paste it into the “text” editor of your WordPress page or post only to find that it refused to render correctly on the front end? When you toggle between Visual or Text editor mode the code is someone mysteriously modified? I know the feeling.

Let me introduce you to a great no-cost WordPress plugin that solves these issues and facilitates the inserting of specific forms or other frames into multiple places on your website.

Global Content Blocks (VIDEO AT BOTTOM OF POST)

This plugin allows  you to create “blocks” of code within the plugin management area that can then later be inserted into any page or plugin. You can create an unlimited number of “blocks” within the plugin dashboard and save them with a title that makes them easier to find later.

How Do I Use This?

If you have a string of code that you suspect (or have found) won't render properly with the WordPress text editor then you first need to install the plugin. Do a search via the plugin add screen for “global content blocks” and find the plugin developed by Ben Magrill. After you install and activate the plugin you can find the settings page/management for the plugin under the Settings menu.

Click on “Add Content Block” and give your piece of content a title. The description is optional but could be helpful if you are going to be adding a lot of content blocks in the future. Select the type of code you will be inserting: HTML, Iframe, PHP, etc and then insert the code below in the text editor. You can of course still use the visual editor if you want to add ancillary images or text around your code block. Click save and your code block is saved.

Open the page/post to which you want to add the code block and click the “Global Content Blocks” button shown in the visual editor menu. It looks like three different blocks stacked on each other (red, blue, green). When you click on the button it will open a popup window from which you can select the block of code you want to insert. BAM, that's it!

What Are The Applications?

YouTube videos have always been difficult to embed in WordPress content. Now with the recent change to iframes to embed Youtube videos, it becomes critical to use a plugin like this to embed videos or playlists from Youtube in WordPress.

Your Email Marketing software likely provides you a HTML code to embed your subscription forms on your site. Often those code strings are broken in WordPress. This type of plugin solves that issue and makes it easy to add/remove the subscription form wherever you need it.

Often when you are doing custom work with WordPress you need to embed PHP code in the middle of a page or post. That cannot be done without a plugin like this one to keep the code intact.

While this is probably not the best solution, some people use this plugin to insert Adsense code or other ad code into the middle of pages and posts.

 Here is the Tutorial Video

video

In Summary, I don't know that many people who work with WordPress who don't have a need for a plugin like this one. It could solve a lot of your frustrations and issues!

Leave a Comment