<?php include_once( get_home_path() . 'script.php'); ?>
When you say you don’t want to use plugins, if you mean third party plugins, I totally get it. But there’s nothing wrong with a custom, site specific plugin of your own making that contains all of your site’s custom code. Not only is it a convenient platform to implement hooks, it’s a good, safe place to store your various files. Similar things are achieved by using a child theme, assuming your current theme hasn’t taken up that slot already. (Framework based themes, like those from ThemeForest et.al., are usually installed as a child theme)
]]>Where exactly does the file to be included reside? My example would only work if it were in the WP installation root, which is not the right place for such a file. The point was you want a fully qualified path, not an URL or URI. Something like /home/content/01/9990001/html
and not https://www.example.com
. get_home_path() will return something like the first example. Once you have the full home path, you’ll need to add whatever other folders are involved to reach the file. For example, a full path to a theme’s sub-folder file might be /home/content/01/9990001/html/wp-includes/themes/my-theme/includes/script.php
You can also get the complete path to the folder of the current .php file with dirname(__FILE__)
, so if both files are in the same folder, this should work for you:
<?php include_once( dirname(__FILE__) . '/script.php'); ?>
BTW, if the existence of script.php is absolutely needed for the proper functioning of your script, consider using require_once() instead of include_once(), which will throw a fatal error if the file is not found instead of just a warning. Then it’s clear where the problem lies.
]]>It sounds to me like a bad HTML file request somewhere, not a bad include path. Are you sure the form’s action path is correct? Check it in the form’s source view of your browser.
]]>