How to Enable Enfold Theme’s Avia Layout Builder for Custom Post Types in WordPress
The Enfold theme is one of the most versatile and popular WordPress themes. It offers a powerful drag-and-drop page builder called the Avia Layout Builder. By default, this builder is available for standard post types such as pages and posts. However, what if you need to use the Avia Layout Builder on a custom post type, such as nd_event?
In this guide, I’ll show you how to enable the Avia Layout Builder for a custom post type by adding a few lines of code to your WordPress theme.
Steps to Enable Avia Layout Builder for Custom Post Types
1. Add Filters for Custom Post Type Support
To allow the Avia Layout Builder to work with your custom post type (e.g., nd_event), you need to use the avf_alb_supported_post_types and avf_metabox_layout_post_types filters. These filters register your custom post type with the builder.
Add the following code to your theme’s functions.php file:
// Enable Avia Layout Builder for custom post type 'nd_event' add_filter('avf_alb_supported_post_types', function ($array) { $array[] = 'nd_event'; // Replace 'nd_event' with your custom post type name return $array; }, 10, 1);
// Enable layout meta box for custom post type ‘nd_event’
function avf_metabox_layout_post_types_mod( array $supported_post_types ) { $supported_post_types[] = 'nd_event'; // Replace 'nd_event' with your custom post type name return $supported_post_types; } add_filter('avf_metabox_layout_post_types', 'avf_metabox_layout_post_types_mod', 10, 1);
2. Replace with Your Custom Post Type Name
In the above code, replace ‘nd_event’ with your custom post type slug. For example, if your custom post type is a portfolio, use ‘portfolio’ instead.
3. Save the Changes
Save the changes once you’ve added the code to your functions.php file. Go to the WordPress admin area and navigate to the custom post-type editor. You should see the Avia Layout Builder available for your custom post type.
Additional Notes
Ensure your custom post type is registered properly and visible in the admin area. If not, you may need to verify the post-type registration code.
If you encounter any issues, check your PHP error logs to ensure no syntax errors in your functions.php file.
By following these simple steps, you can extend the functionality of the Enfold theme and make your custom post types more dynamic with the Avia Layout Builder.