Title: Error using template file
Last modified: January 2, 2020

---

# Error using template file

 *  Resolved [ElectricFeet](https://wordpress.org/support/users/electricfeet/)
 * (@electricfeet)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/error-using-template-file/)
 * Further to my [previous question](https://wordpress.org/support/topic/is-there-an-easy-way-to-align-mornings-and-afternoons-horizontally/)
   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 an `is-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?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [janizde](https://wordpress.org/support/users/janizde/)
 * (@janizde)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/error-using-template-file/#post-12289654)
 * Hi [@electricfeet](https://wordpress.org/support/users/electricfeet/) ,
 * nice that you have managed to get it working with the filter 🎉
    Referring to
   the example usage of the filter ( [https://github.com/janizde/WP-Opening-Hours/blob/master/doc/filters.md#op_shortcode_template](https://github.com/janizde/WP-Opening-Hours/blob/master/doc/filters.md#op_shortcode_template))
   you can see that you can check the kind of shortcode with `if ($shortcode instanceof
   ShortcodeModule)`. In your case it should be the `OpeningHours\Module\Shortcode\
   Overview` then.
 * Cheers
    Jannik
 * If you have further questions you can reply in this thread, I’ve enabled email
   notifications for this.
 *  Thread Starter [ElectricFeet](https://wordpress.org/support/users/electricfeet/)
 * (@electricfeet)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/error-using-template-file/#post-12290879)
 * [@janizde](https://wordpress.org/support/users/janizde/) Thanks Jannik!
 * That worked a treat.
 * Unfortunately, the documentation is a little beyond my competence level so I 
   had previously seen the link you gave above and stripped out all the stuff I 
   didn’t understand, with inevitable results :-)))
 * (I still don’t understand classes and the `use` statement, but as an incantation
   to the php gods, it works, so I won’t omit it again.)
 * I can now combine the is-open shorcode with the overview shortcode on the same
   page with no problems.
 * Thanks again for all your patient help.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Error using template file’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-opening-hours_3e2c4f.svg)
 * [Opening Hours](https://wordpress.org/plugins/wp-opening-hours/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-opening-hours/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-opening-hours/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-opening-hours/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-opening-hours/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-opening-hours/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [ElectricFeet](https://wordpress.org/support/users/electricfeet/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/error-using-template-file/#post-12290879)
 * Status: resolved