Loomisoft’s Reusable Content & Text Blocks plugin allows you to define modular and repeated blocks of text and other content and place them within pages, posts, sidebars, widgetised areas or anywhere on your site via shortcodes, via the provided widget or via PHP.
The idea behind this plugin is two-fold. The first is to modularise content so you can use the same content in multiple pages, posts and other places. The second is to provide an easy way to add complex custom content within sidebars and widgets.
This latest version also supports WPBakery’s Visual Composer, Avada’s Fusion Builder, Beaver Builder and SiteOrigin Page Builder.
- Uses WordPress custom post type and custom post management to define reusable content blocks
- Allows the use of shortcodes, widgets and PHP to place content blocks into pages, posts, sidebars, widgetised areas or anywhere on your site
- Provides a widget to place content blocks into sidebars and other widgetised areas
- Supports WPBakery’s Visual Composer, Avada’s Fusion Builder, Beaver Builder and SiteOrigin Page Builder
- Provides a number of other useful shortcodes to place dynamic text (e.g. date/time, site title, page title) into posts
Defining content/text blocks
Content or text blocks can be added and managed via the custom “Content Blocks” post type. Once defined, they can be used in your posts, pages and other areas in your site.
Content blocks can be added to your pages, posts or anywhere in your site that accepts shortcodes by using the content block’s post ID or slug using the following format:
You can also have the normal WordPress paragraphs added automatically by having:
[ls_content_block id=”<ID>” para=”yes”]
[ls_content_block slug=”<SLUG>” para=”yes”]
A custom widget is provided so you can easily add content blocks to your sidebars and other widgetised areas.
Access via PHP
Content blocks can be added to your customised theme pages via PHP using the following code:
<?php echo ls_content_block_by_id( <ID> ); ?>
<?php echo ls_content_block_by_slug( ‘<SLUG>‘ ); ?>
To have the normal WordPress paragraphs added automatically, use:
<?php echo ls_content_block_by_id( <ID>, true ); ?>
<?php echo ls_content_block_by_slug( ‘<SLUG>‘, true ); ?>
Use of Visual Page Builders
This latest version supports WPBakery’s Visual Composer, Avada’s Fusion Builder, Beaver Builder, SiteOrigin Page Builder and possibly others (although others have not been tested).
To use this feature, you will need to:
- If relevant to the specific page builder, enable the “lscontentblock” or “Content Blocks” post type within its settings
- For shortcodes, use the para=”yes” attribute as described above
- For the widget, tick the “Automatically add paragraphs” checkbox
- In the case of the widget, set the second parameter to true
Content blocks within content blocks
If needed, content blocks can be used within other content blocks via shortcodes as described above. A safety feature has been written into this plugin to suppress circular references.
Other useful shortcodes
This plugin also provides the following useful shortcodes, which can be used within content blocks as well as other places such as pages/posts:
Date & time:
(Using the standard PHP date format strings – see http://php.net/manual/en/function.date.php)
[ls_content_block datetime=”<DATE/TIME FORMAT>“]
For example, the current date in dd/mm/yyyy format would be:
(As set in WordPress admin area – Settings > General)
Title of current page/post:
(Note that this is the raw title of the page/post and not the same as the title within the HTML <title> tag, which can be changed by SEO plugins)