Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Include custom templates in Elementor template library (Not My template) #5860
What problem is your feature request going to solve? Please describe.
I know there are many issue about the custom library like #454 and #3127.. But those issue are about improving My templates. Mine is not about My templates, it's about to append templates to Elementor built-in library.
Describe the solution you'd like
changed the title
Extend Elementor Library. Include custom template/block in Elementor template library (Not My template)
Oct 5, 2018
This would be great, especially if it allowed us as theme Devs to filter out the existing prebuilt templates. It's one of the main hurdles we have (along with being able to create custom widgets with drop zones aka custom sections) in bringing elementor into our larger projects.
Here is what I got so far. I'm able to list and import my custom templates
I can include my custom templates in template list of Elementor: http://prntscr.com/l32jqh. Currently I'm using a function that get library data from Elementor, then I add my templates to it before save to
Because Elementor only download template data from its server, we need a filter to tell it where to download our template. I did it by modifying
Then I add a filter base on
Listing and inserting template work perfectly!
referenced this issue
Oct 7, 2018
There is no need to wait, we can already do what you're asking for since a while. You simply need to do it differently. Here's an example for filtering all pro templates from the list. But basically, you could append new templates the same way.
Simply add the following in your functions.php file (or build a plugin with it if needed) and edit it as needed:
Like I said, in this example, I'm removing the pro templates from the library, but it's just so you can see what can be done. Simply use
In order to see the changes in the library, you might need to refresh it by pressing on the refresh button, since the array is edited when updating the 'elementor_remote_info_library' option (which is updated when refreshing the templates).
@sf-steve Elementor loads template data from their server, you can see my rejected PR above.
@davelavoie Your idea is great! I didn't think about
@dinhtungdu Sure, feel free to use this idea! If you want, you can give me credit by mentioning my name with a link pointing to the URL displayed on my GitHub profile :-)
@sf-steve Well, since you can override the whole list of templates with the hook I've shared, you could technically fetch templates from your own source using wp_remote_get. You just need to make sure the data returned has the same format as the one used by the default source. To see how the default data is formatted, open the console in Chrome, click on the "Sync Library" button, and inspect the request (see attached screenshot for an example)
This is not the only way to do it though, but this is clearly the easiest way.
By the way it's already possible to replace the default remote source with your own, and it has been possible for many years. I've once replaced the default source with my own on a WP multisite environment, all templates were saved on the main site (with blog ID = 1), and all subsites were able to fetch the list of saved templates from the main site instead of fetching them from the default source.
I might eventually release a plugin that allows anyone to replace the default remote source with their own source if I have enough time, but meanwhile, for those who want to get started, you can do the following:
Then, you must create a class for your custom source. You can see how the current sources are built by taking a look at the
Your custom source should be defined this way (this is not a complete example, and it's not tested!):
Now, you have everything you need to override the default remote source ;-)
I plan to create this kind of plugin, I just didn't have the time yet. I'll update this thread once it's available (though I can't tell if it's going to take just a few weeks or a few months right now)