Support » Plugin: WP Store Locator » Custom template won’t load

  • Resolved Nick Young

    (@nickyoung87)


    Hello,

    I am having an issue getting a custom template to load. I have already viewed the recently closed topic here: https://wordpress.org/support/topic/template-doesnt-change/

    But that did not help.

    I have also looked around for other solutions but have not been able to find out why it’s not working.

    Here is a gist of the functions.php function I am using: https://gist.github.com/nickyoung87/73c6190f73755096a2595dd0ecdeb03c

    Other info:
    – WordPress version is the latest version
    – WPSL is the only plugin activated and is using the latest version
    – Using Twenty Seventeen theme (no child)
    – I have setup the Google API keys
    – I have set the custom template from the dropdown in the settings
    – I have made sure the custom template file does in fact exist in the theme folder at the correct location
    – No console errors present
    – Tried changing the priority on the filter to 99 just in case it was conflicting somehow with another filter even though there is not any.
    – Fails both on my localhost setup and on the live website example provided.
    – I tried sprinkling a few debugging output lines in the plugin. One in particular that confused me was in the class-templates.php file in the function get_default_template. It was always outputting store_locator as the type for me.
    – Also in class-templates.php the function get_template_details was always outputting the below_content value for the $used_template variable.

    Not sure if that is helpful with the debugging as I didn’t dig super deep to trace everything and find out if that was even related to the issue, but just something I noticed and thought I should point out in case it does help.

    My only other concern is maybe there is something wrong with my template file? Right now I just have one line of PHP in there to test it: echo 'TESTING'; but I have tried copying the default template from the plugin folder and making small changes and that still didn’t seem to change it.

    Any thoughts or suggestions here?

    Look forward to your response, thanks!

    • This topic was modified 2 years, 1 month ago by Nick Young.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    Can you include the code below on line 715 here, and check if the path is correct.

    
    echo $template_details['path'];
    exit();
    

    The line 715 that you linked me to is in version 2.2.10 and I am currently running 2.2.14 so that line is a bit different. I am going to try reverting to 2.2.10 and see if that helps and then report back here.

    If not then it looks like the new line would be around 694 in 2.2.14 correct?

    Ok so it doesn’t work for me on 2.1.10 either I just finished checking.

    While I have it installed though I added the code you suggested and got this:

    Notice: Undefined variable: template_details in /home/nyoung87/public_html/plugins/wp-content/plugins/wp-store-locator/frontend/class-frontend.php on line 718

    So I changed it to this:

    echo $template_path;
    exit();

    And that got me this:

    /home/nyoung87/public_html/plugins/wp-content/plugins/wp-store-locator/frontend/templates/store-listings-below.php

    So it is always calling the below template it looks like.

    Oh my gosh I am an idiot and I am sorry to waste your time. I just double checked the shortcode on the page and it was using the template attribute. Removed that and we are all good now.

    So sorry and thanks for the plugin!

    Plugin Author Tijmen Smit

    (@tijmensmit)

    Well, that happens to me sometimes as well when I test code. Setting a template through the shortcode and wondering why it doesn’t use the selected template from the settings page 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom template won’t load’ is closed to new replies.