Toolbox for Beaver Builder

Toolbox Shortcodes

You can use shortcodes to do almost anything in WordPress. You can also use Toolbox shortcodes to get whatever field and apply whatever template you want inline.

Every setting that is available in the Modules, is also available in the shortcodes. So, if you're extending to accept more parameters, you can also use those to alter the results of a [toolbox] shortcode.

There are three shortcodes that you can use:

  • [toolbox]
  • [toolboxwp]
  • [toolboxtwig][/toolboxtwig]

[toolbox]

The toolbox shortcode is the main shortcode for this plugin. It is used to retrieve a field render it to the browser.

You can use it like this:

[toolbox field="fieldname"]

But you can also provide your settings while requesting the field:

[toolbox field="company_logo" size="medium" tag="true"]

would get the company_logo field from this post. It retrieves the medium sized thumbnail and adds tags around the url, adds the title- and alt-tag if it's stored as an Array or ID in the database. It also applies default alignment.

NOTE: How these settings are handled is manageable by the toolbox/helpers/get_acf_field/type={fieldtype} filters.

Applying Twig templates

You can also directly apply a Twig template to the field. This is useful when you want to return a repeater inline, inside another module for instance.

Simply create or copy a twig template to the Twig Templates CPT. Make sure to create a template of type inclusion.

Now add the shortcode:

[toolbox field="myrepeater" twigtemplate="mytemplate"]

The field 'myrepeater' will be passed through the 'mytemplate' template and rendered to the browser.

[toolboxwp]

The toolboxwp shortcode is used to get information from wp and render it to the browser, according to the filters set in the toolbox/helpers/get_wp_field/type={returntype} filter.

the toolboxwp shortcode can retrieve the following information:

  • title
  • featuredimage
  • media
  • content
  • excerpt
  • permalink
  • publish
  • modified
  • author
  • comments
  • avatar
  • previous_post
  • next_post

You can use toolboxwp like this:

[toolboxwp field="title"]

to pull the post title.

[toolboxwp field="featuredimage" size="medium" tag="true"]

to pull the featured image of the post, with size medium and a tag surrounding the retrieved url.

[toolboxtwig][/toolboxtwig]

The toolboxtwig shortcode is useable when the Timber-library is enabled. The contents of the shortcode is the Twig template that will be processed by the Twig engine.

When calling the shortcode you can also pass in a fieldname:

[toolboxtwig field="myfieldname"]{{__field__}}[/toolboxtwig]

When providing the field attribute it will return the variables __field__ and __field__object for convenience. Respectively they will be the returned value for ACF's get_field() and get_field_object() functions.

In this section:

  • Toolbox Shortcodes
Last modified: October 30th, 2018