Error using template file
-
Further to my previous question about formatting opening times horizontally, I went down the template route and modified the template.
I added the call to my modified template in my child theme’s functions.php with:
add_filter('op_shortcode_template', 'specify_different_template', 10, 2); function specify_different_template( $template, $shortcode ) { return '../../../themes/my-child-theme/wp-opening-hours/orari.php'; }
It works great for the op-overview shortcode.
Unfortunately, the code above seems to be forcing the same template for the
is-open
shortcode. This gives a fatal error if I add anis-open
shortcode. Specifically, I get:
Fatal error: Uncaught Error: Call to a member function getDescription() on null in /...path-to-my-wordpress.../wp-content/themes/my-child-theme/wp-opening-hours/orari.php:29 Stack trace: #0 /...path-to-my-wordpress.../wp-content/plugins/wp-opening-hours/classes/OpeningHours/Util/ViewRenderer.php(35): include() #1 /...path-to-my-wordpress.../wp-content/plugins/wp-opening-hours/classes/OpeningHours/Util/ViewRenderer.php(44): OpeningHours\Util\ViewRenderer->render() #2 /...path-to-my-wordpress.../wp-content/plugins/wp-opening-hours/classes/OpeningHours/Module/Shortcode/AbstractShortcode.php(145): OpeningHours\Util\ViewRenderer->getContents() #3 /...path-to-my-wordpress.../wp-content/plugins/wp-opening-hours/classes/OpeningHours/Module/Shortcode/IsOpen.php(86): OpeningHours\Module\Shortcode\AbstractShortcode->renderShortcodeTemplate(Array, '/...path-to-my-wordpress...') #4 /...path-to-my-wordpress.../wp-content/plugins/wp-opening-hours/classes/OpeningHours/Module/Shortcode/AbstractShortcode.php(97): OpeningHours\Module\Shortcode\Is in /...path-to-my-wordpress.../wp-content/themes/my-child-theme/wp-opening-hours/orari.php on line 29
(Line 29 is in the original overview template and reads:
$description = $set->getDescription();
. But I’m pretty sure it shouldn’t be picking up my template anyway.)What do I need to specify in my functions.php to tell the plugin to override the overview template, but not the others?
- The topic ‘Error using template file’ is closed to new replies.