Overriding a Template doesn't work
-
Overriding a Template doesn’t work for me.
I’m doing overriding using this guide https://lifterlms.com/docs/lifterlms-templates/
https://wordpress.org/plugins/lifterlms/
[moderated to fix link]
-
Which templates are you attempting to override and where on your server are you placing the files? Can you give me the path from the WordPress root?
Thanks,
For example featured-image.php from course directory located under lifterlms in the plugins directory.
I’m copying it to themes/my theme directory under structure I have created which is /lifterlms/course/featured-image.php
I’m not seeing any issues with this functionality. What exactly are you attempting to accomplish here and are you certain the template isn’t responding?
The featured image being displayed might be being output by your theme (not LifterLMS).
Can you provide me a working link where you’re override is not working so I can check it out and advise as to whether or not the featured image is being output by LifterLMS or your theme?
Thanks,
For example: featured-image.php contains that code:
if ( ! defined( 'ABSPATH' ) ) { exit; } global $post; ?> <div class="post-thumbnail"> <h1 class="llms-featured-image"> <?php echo lifterlms_get_featured_image_banner( $post->ID ); ?> </h1> </div>
I can style element by css but I can also add class directly here:
<div class="post-thumbnail"> to <div class="post-thumbnail well">
But there is no changes when I’m inspecting code on the site.I assume that there is no need for doing something else other than copying files into proper location.
I’m really sorry but I am completely unable to recreate your issue. Template overrides appear to be working as documented.
Perhaps we’re dealing with an issue specific to your theme what theme are you using?
I’d still love to see a link to the site in question, if possible.
Also, do you have any caching enabled? Try disabling the cache if you are.
Thanks,
I’m using my own theme based on bottstrap. Here is the link to the site which contains single course.
I have changed featured-image.php like is mentioned in above post.Link to the site: KLIK
Unfortunately it doesn’t appear to be working. I can’t recreate this issue and the best I can. I can’t build your theme for you but if you’d like me to review your actual code I can do my best to see. I will not do this for our free customers in the forum though, if you need further assistance please consider subscribing to LifterLMS Pro and opening a new support ticket. You can send me a copy of your theme and I’ll review it locally and see what’s going on in your theme that’s preventing the template overriding to function correctly.
Take care,
I’m so embarrassed but it was my fault.
Instead for creating structure like my-theme/lifterlms/course/featured-image.php I was creating my-theme/lifterlms/templates/course/featured-image.php.
In post above the path is ok but my “creation process” was mistaken.
Of course now everything works fine 😉
Sorry for trouble and very much thank You.
PS.
I think there is a bug in that code:
function my_llms_theme_override_dirs( $dirs ) { $dirs[] = plugins_dir_path( __FILE__ ) . '/lifterlms'; return $dirs; } add_filter( 'lifterlms_theme_override_directories', 'my_llms_theme_override_dirs', 10, 1 );
Should be plugin_ instead of plugins_ word?
You’re right… I guess no one is overriding from a plugin.
I’ll get that resolve in a future release.
Take care,
BIG THX
Cleaning up old tasks, this appears to be a typo in documentation, not the codebase.
Cleaned it up. Let me know if you need anything else
- The topic ‘Overriding a Template doesn't work’ is closed to new replies.