Code Archive - beaverplugins https://beaverplugins.com/code/ Plugins and Modules for the Beaver Builder Mon, 06 Nov 2023 20:00:32 +0000 en-US hourly 1 https://beaverplugins.twic.pics/2016/07/cropped-beaverplugins_logo-2-32x32.png Code Archive - beaverplugins https://beaverplugins.com/code/ 32 32 HTMX Requests https://beaverplugins.com/code/htmx-requests/ Mon, 06 Nov 2023 16:20:41 +0000 https://beaverplugins.com/?post_type=code&p=3731 Starting with Toolbox 1.4.0 you can enqueue the HTMX javascript library and register AJAX requests using Twig templates. But what are they? Dynamic content If you’ve ever tried to register an AJAX call in WordPress, you know what a pain it can be to simply return a partial layout. You need to add an action-hook…

The post HTMX Requests appeared first on beaverplugins.

]]>
Creating a custom taxonomy filter https://beaverplugins.com/code/creating-a-custom-taxonomy-filter/ Fri, 10 Jun 2022 13:16:00 +0000 https://beaverplugins.com/?post_type=code&p=3169 You can create custom filters for your layouts using Twig templates without the need for additional plugins. The fun part is that you can tweak them to your own needs and reuse them on other projects if needed. Let’s start by adding a filter that allows us to select a taxonomy and filter our posts…

The post Creating a custom taxonomy filter appeared first on beaverplugins.

]]>
Using a PostQuery in your Template https://beaverplugins.com/code/using-a-postquery-in-your-template/ Tue, 08 Mar 2022 03:16:00 +0000 https://beaverplugins.com/?post_type=code&p=3138 No more tb.get_posts() ! You can do a Timber PostQuery inside your Timber Posts Modules from now on. Added in Toolbox 1.2.3 Make sure to update your Toolbox version before using the PostQuery function Previously, when doing a query inside the Timber Posts module you needed to use tb.get_posts(), but had to fetch a seperate…

The post Using a PostQuery in your Template appeared first on beaverplugins.

]]>
Adding Global Twig Variables https://beaverplugins.com/code/adding-global-twig-variables/ Mon, 07 Feb 2022 03:03:00 +0000 https://beaverplugins.com/?post_type=code&p=2812 Have you ever had the need to set global variables that can be used across multiple Twig templates? Then you might have tried to create a Twig Template, set a few variables and included that in another template, only to discover that you couldn’t get to those variables because they are scoped to the original…

The post Adding Global Twig Variables appeared first on beaverplugins.

]]>
Tabs by month https://beaverplugins.com/code/tabs-by-month/ Sun, 26 Dec 2021 15:04:34 +0000 https://beaverplugins.com/?post_type=code&p=2948 If you want to avoid the clutter of listing all posts as one big list, you might consider grouping them in accordions by month for instance. But how would you be able to do that yourself? You can do that easily in Toolbox using the Timber Posts module!

The post Tabs by month appeared first on beaverplugins.

]]>
Adding a masonry grid https://beaverplugins.com/code/adding-a-masonry-grid/ Sun, 26 Dec 2021 13:50:51 +0000 https://beaverplugins.com/?post_type=code&p=2935 A masonry grid is when you have items that are laid out one after the other in the inline direction. When items move onto the next line, they will also move up into any gaps left by shorter items in the first line. Here’s an example: Adding Timber Posts module This is a good time…

The post Adding a masonry grid appeared first on beaverplugins.

]]>
Relationship Fields https://beaverplugins.com/code/relationship-fields/ Sun, 26 Dec 2021 13:37:36 +0000 https://beaverplugins.com/?post_type=code&p=2932 When creating a WordPress website that makes use of relationships between Custom Post Types, it is key that you can extract the relationships and render the information the way that you want it, not just the way that a 3rd party plugin allows you to. Toolbox gives you the tools to do that very easily.…

The post Relationship Fields appeared first on beaverplugins.

]]>
Why I use macros for everything https://beaverplugins.com/code/why-i-use-macros-for-everything/ Fri, 24 Dec 2021 11:20:59 +0000 https://beaverplugins.com/?post_type=code&p=2829 Okay, so I get that this is a pretty spammy title. But Twig macros are just awesome to use all over your templates. They’re like the CSS-classes of HTML. What is a macro? A macro is a re-usable piece of code, sort of what a function is in PHP. A macro can be used directly…

The post Why I use macros for everything appeared first on beaverplugins.

]]>
Use Timber to create ACF Blocks https://beaverplugins.com/code/use-timber-to-create-acf-blocks/ Sun, 28 Mar 2021 16:11:00 +0000 https://beaverplugins.com/?post_type=code&p=2743 Timber is a very easy and convenient way to add PHP to your site. Toolbox can be used to leverage the Timber Library plugin and Twig templates to generate code very fast, using the Timber Posts Module in Beaver Builder or to execute templates using the toolboxtwig shortcode (see this article). But you can also…

The post Use Timber to create ACF Blocks appeared first on beaverplugins.

]]>
Using Toolbox to generate shortcodes https://beaverplugins.com/code/using-toolbox-to-generate-shortcodes/ Thu, 25 Mar 2021 11:03:41 +0000 https://beaverplugins.com/?post_type=code&p=2717 Shortcodes aren’t the prettiest thing to use on a WordPress website. And some will go as far as to say that you should avoid them at all cost. But they can also be very useful, are fairly useful to use and above all, they’re pretty safe because users can use them, but don’t need to…

The post Using Toolbox to generate shortcodes appeared first on beaverplugins.

]]>