• Hi Greg,
    struggling a little with adding your mod for overiding templates as seen here: https://wpadverts.com/doc/child-themes-and-templates/

    Looks like others have experienced the exact same issue here: https://wordpress.org/support/topic/override-templates-9/
    My conditions and results are the same as Sergey (@sergey561).

    Was there a resolve for this?

    Trying to mod the list.php file. My changes are reflected perfectly in the default location: wpadverts/templates/list.php. When applying the mod I don’t see any changes.

    As you suggested, I did a little debugging by adding “function override_templates( $tpl ) { echo “OK.”;” to the overides-template.php and indeed I saw “OK” in the search form. Looks like the file is not being pulled.

    Pasting the function directly in the child-theme functions.php crashed the site!
    Should have worked in there also right?

    Any pointers?
    FTP showing file location at: /public_html/wp-content/themes/my-theme/wpadverts/list.php

    Regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    usually, the problem with the override-templates snippet is that the users do not have the child-template files in the correct directory.

    You seem to have it in the correct place assuming your current theme folder name is ‘my-theme’. Can you paste a link to your website and a screenshot from the FTP software showing the path to the file?

    As for the error on site, i am not sure what it was, if you could post here an error message you saw then i should be able to tell what caused it.

    Thread Starter Perce2

    (@perce2)

    Hi Greg,

    yes, I double checked and made sure the template snippet is in the correct location. In fact, have tried it in various locations just to make sure.

    The site is still in development (not live) and the path I provided is correct, just changed the “my-theme” name in the path.

    The error I was referring to was just the default WP “There has been a critical error on your website”, no clues. Normally only when something is very wrong.

    How up to date is the snippet code? Could be an issue with it and the latest WP version being used 5.6? Maybe you could verify it’s still current?

    Regards

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    i tested the code yesterday with the latest WPAdverts and WP, it is working fine for me.

    One note, if you are using a child-theme then the script will check for the templates in your parent theme directory, it does not have code to look in the child theme folder.

    To check in the child theme, in the override-templates.php replace get_template_directory() with get_stylesheet_directory().

    As for the error message, to find out an actual error message you would need to open file wp-config.php add there the line define( "WP_DEBUG", true ); and replicate the error, you should see the error then.

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

The topic ‘Override templates’ is closed to new replies.