Including PHP files doesn’t work outside of Localhost

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).

Read More

Any ideas?

Related posts

Leave a Reply

3 comments

  1. The correct way to load a PHP file in the theme directory is to use the locate_template function.

    <?php locate_template(array('parts/block1.php'),true,false); ?>
    

    The true makes it automatically require it. The false makes it not require_once it.

  2. I included the file product-menu.php by using

    <?php get_template_part( 'product-menu'); ?>
    

    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