Customing templates when theming is disabled
-
Love this plugin!
I’m trying to customize the autocomplete dropdown by modifying the autocomplete.php template as specified in the Customization section of the Customize the Autocomplete dropdown documentation.
The problem is that I am not using the WordPress theming system. I am using the Oxygen builder, which disables it completely. Thus I do not have an active theme and cannot add the templates folder to an active theme.
I use a custom plugin (
WP_PLUGIN_DIR.'/custom-functions/'
) for code that I’d typically put in a theme’s functions.php. I would like to load the templates from the plugin instead of from a theme. The templates are within the algolia folder within my custom plugin (WP_PLUGIN_DIR.'/custom-functions/algolia/'
).I (incorrectly) attempt to load these templates using the following code:
// Load custom algolia templates function algolia_page_templates($template) { if ('instantsearch.php' == basename($template)) { $template = WP_PLUGIN_DIR . '/custom-functions/algolia/instantsearch.php'; } else if ('autocomplete.php' == basename($template)) { $template = WP_PLUGIN_DIR . '/custom-functions/algolia/autocomplete.php'; } return $template; } add_filter('page_template', 'algolia_page_templates');
But this does not result in the loading of my customized templates; there is no noticeable change.
I used these template names because that’s what they are named in the class-algolia-template-loader.php file within this WP Search with Alolia plugin.
Please let me know what I can do to load my custom templates from a plugin instead of through a theme.
Thank you ??
- The topic ‘Customing templates when theming is disabled’ is closed to new replies.