Dynamic content (Visual Composer Premium feature) allows you to replace static content in content elements with WordPress default or custom meta fields. This means you can transform a regular text block into a post title or a single image into a featured image.
For more advanced options, you can create a template with dynamic content placeholders and use it in your pages, posts, or custom post types.
Dynamic content allows you to connect any custom fields of your site:
- WordPress default meta fields;
- Custom meta fields;
- WooCommerce (compatibility);
- ACF (compatibility);
- Toolset (compatibility).
How to Use Dynamic Content?
Dynamic content can be connected to any element of Visual Composer that generates static content (ex. Text block, single image, button, hero section, etc.). To add dynamic content:
- Open element edit window (ex. Simple Button);
- Locate attribute related to static output (ex. Button text);
- Click on the dynamic content icon next to the attribute;
- Select dynamic content type from the dropdown (ex. Post title).
- Addition: Select different source (by default current post is set by default);
At this point, you will see that the button text has been changed to your post title.
Apart from text, you can also specify images to be replaced with dynamic content (ex. featured image). In addition, dynamic content works with images in Design Options.
Dynamic content is available for the following attributes:
- Inputs (that generate static output);
- Link Selector;
The unique feature of Visual Composer dynamic content is an option to style dynamic content connected to TinyMCE. This means that after connecting dynamic content to TinyMCE, you will have an option to use styling options.
Dynamic content source
By default, dynamic content uses WordPress fields and custom fields from the current post. Although, it is possible to specify a custom post source and get custom meta fields from it.
Important: If you are creating a template with dynamic content, make sure to leave ‘Set custom post source’ toggle off. This will make sure that dynamic content will be taken from the post where the template is inserted.
What if my custom fields are not listed?
Visual Composer team regularly expands the compatibility with the most popular WordPress plugins that operate with custom fields. The custom fields from those plugins will be listed in the dropdown together with WordPress default fields.
If your custom field is not listed in the dropdown, select ‘Other’ and specify the ‘meta key’ of your custom field. Your custom field will be automatically connected.
Dynamic Content and Global Templates
The ultimate power of Dynamic Content is the ability to combine with Header, Footer, Sidebar editor or Global Templates. In Visual Composer, you can create a global template or header which uses the placeholders for Dynamic Content (ex. post title or featured image background). Once you have a template, apply it to your posts and the template will automatically fill the placeholders with dynamic content from the current post.