WordPress
Embedding the widget in WordPress using Elementor or the built-in editor
Introduction
The Regular Quote Widget is an embeddable <script>
and can be easily integrated into various website builders, as well as custom coded websites.
What is important is properly setting up the Host URL in the Quote Widget settings. This URL is important, because it serves as a security measure, preventing 3rd parties from copying your Quote Widget.
Many WordPress Modal/Drawer plugins or elements include a tabindex="-1"
attribute which can cause issues with the Regular Quote Widget. If you wish to embed the widget into a modal or drawer, make sure it functions correctly.
Embedding via Elementor
If you wish to add the Quote Widget to a page using the Elementor page builder, follow these steps:
- Log into your WordPress Admin
- Navigate to the page you wish to add the Widget to or create a new one
- Toggle the Elementor Builder
- Look for the
</> HTML
block and add it to the page - Copy the Embed code with your preferred language from the BuildPlateZ platform. The code should look something like this:
<script>
(function (w, d, s, o, f, js, fjs) {
w['bpz-regular-widget'] = o; w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
js.id = o; js.src = f; js.async = 1; js.type = 'module'; fjs.parentNode.insertBefore(js, fjs);
}(window, document, 'script', 'bpzRegularWidget', 'https://quote-regular.buildplatez.com/assets/index.js'));
bpzRegularWidget('init', { widgetKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', lng: 'en' });
</script>
- Paste the Embed code into the HTML Code section of the block
- Add a
<div>
element with the id equal to your widget key where you want the Widget to appear. For example:
<div id="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"></div>
- The Quote Widget should appear in the section.
- Preview the page to make sure the Widget is displayed and works as expected.
- Save your changes and publish the page.
Embedding via the build-in WordPress Editor
If you wish to add the Quote Widget to a page using the built-in WordPress page builder, follow these steps:
- Log into your WordPress Admin
- Navigate to the page you wish to add the Widget to or create a new one
- Begin editing the page
- Add the
Custom HTML
block to the page content. - Copy the Embed code with your preferred language from the BuildPlateZ platform. The code should look something like this:
<script>
(function (w, d, s, o, f, js, fjs) {
w['bpz-regular-widget'] = o; w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
js.id = o; js.src = f; js.async = 1; js.type = 'module'; fjs.parentNode.insertBefore(js, fjs);
}(window, document, 'script', 'bpzRegularWidget', 'https://quote-regular.buildplatez.com/assets/index.js'));
bpzRegularWidget('init', { widgetKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', lng: 'en' });
</script>
- Paste the Embed code into the Custom HTML block.
- Add a
<div>
element with the id equal to your widget key where you want the Widget to appear. For example:
<div id="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"></div>
- Toggle the Preview of the block.
- The Quote Widget should appear in the section.
- Preview the page to make sure the Widget is displayed and works as expected.
- Save your changes and publish the page.
Improving performance
The script tag of the widget is loaded asynchronously, which means it won't block the rendering of the page. However, it's recommended to add the script tag at the end of the body tag to ensure the page is rendered before the widget is loaded. This will improve the performance of your website.
Depending on the WordPress theme and plugin set you are using, you should be able to add the script tag to the end of the page.
<body>
<!-- Your website content -->
<script>
(function (w, d, s, o, f, js, fjs) {
w['bpz-regular-widget'] = o; w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
js.id = o; js.src = f; js.async = 1; js.type = 'module'; fjs.parentNode.insertBefore(js, fjs);
}(window, document, 'script', 'bpzRegularWidget', 'https://quote-regular.buildplatez.com/assets/index.js'));
bpzRegularWidget('init', { widgetKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', lng: 'en' });
</script>
</body
You can still place the <div>
element wherever you want the widget to appear. The widget will be rendered in the place where the <div>
element is located. Adding the <div>
element can either be done with a custom HTML block or by adding an ID to an existing div element.
You can further improve the loading speed by including a preload tag in the head of your WordPress website. Once again, how this is done will depend on the Theme and plugins you are using, so refer to their documentations for details.
<head>
<!-- Your website content -->
<link rel="preload" href="https://quote-regular.buildplatez.com/assets/index.js" as="script">
</head>
This will preload the widget script and improve the loading speed of the widget.