I have a bunch of widgets that I load from php files, like so:
I added a PHP CODE widget and inside wrote:
<?php
include '/wp-content/themes/myTheme/parts/block1.php';
?>
This worked well on my localhost, but for some reason it stopped working
when I uploaded that website online (and switched the home and site_url of course).
Any ideas?
The correct way to load a PHP file in the theme directory is to use the locate_template function.
The true makes it automatically require it. The false makes it not require_once it.
I’ve had similar problems. You may want to use the built in WordPress constants:
I included the file product-menu.php by using
and I thought I’d put a code into the top of it to mark it as being the product menu – but turns out that I didn’t