Wednesday 22 February 2017
How to include a PHP file inside WordPress php template?
Answer
Answer
This is the code I have inside php
tags:
include('/wp-content/custom-php/numberedSteps.php');
And I get this error:
Warning: include(/wp-content/custom-php/numberedSteps.php): failed to open stream:
No such file or directory in /home/user/public_html/website.com/wp-content/themes/flatsome/woocommerce/archive-product.php on line 85
Warning: include(): Failed opening '/wp-content/custom-php/numberedSteps.php' for inclusion (include_path='.:/usr/local/php56/pear') in /home/user/public_html/website.com/wp-content/themes/flatsome/woocommerce/archive-product.php on line 85
How can this error be fixed?
Answer
try getting the root path first
for PHP >= 5.3.0 try
include(__DIR__.'/wp-content/custom-php/numberedSteps.php');
For PHP < 5.3.0 try
include(dirname(__FILE__).'/wp-content/custom-php/numberedSteps.php');
c++ - Does curly brackets matter for empty constructor?
Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...
-
A fair amount of the second act of The Dark Knight Rises has a class warfare plotline. This is foreshadowed in the trailers with Selina Ky...
-
I want to create an options array from a string. How can i create an array as { width : 100, height : 200 } from a string ...
-
I'm still trying to wrap my head around how the following expression results in undefined behavior: a = a++; Upon searching SO...
No comments:
Post a Comment