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.

Defining content 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.

Shortcodes

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:

[ls_content_block id="<ID>"]
[ls_content_block slug="<SLUG>"]

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"]

Widgets

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 Composer within content blocks

The Loomisoft content blocks are designed to allow the use of the Visual Composer editor. To do this, you will need to enable the “lscontentblock” post types within Visual Composer Role Manager.

However, please note that settings you specify within an element’s “Design Options” (e.g. margins, paddings, borders, background, etc.) will not show in the front end. This is because of the way Visual Composer labels these as custom CSS settings related to the containing post – in this case the content block post and not the page/post where it appears.

The best way to customise these design options is to label the element with an “Extra class name” or “Row ID” and then add these to a custom CSS.

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:

[ls_content_block datetime="d/m/Y"]

Site title:
(As set in WordPress admin area – Settings > General)

[ls_content_block info="site-title"]

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)

[ls_content_block info="page-title"]

Screenshots

Get this Plugin

This plugin is available in the normal WordPress admin area Add Plugin page and may also be downloaded from the WordPress.org website.

Make a financial contribution

This plugin is provided free of charge. However, if you like it, feel free to make a financial contribution. Your contributions allow us to provide support, upgrades and bug-fixes for this plugin and of course they help with the development of other useful plugins.