0

I wrote a bunch of functionality (3 function files, search.php, query.php and vcard.php) I'm trying to bring their functionality into my Wordpress theme. Once brought into the WordPress themes root folder I get 404 errors when I try to call the functions as I did on the test site no matter what I do. ie ../, /, ./, etc.

Do I HAVE TO put my functions inside functions.php? Do I have to register my function files? Any help would be great! Thanks.

1 Answer 1

1

You can include the files from functions.php. You define the constant OF_FILEPATH based on whether or not you are in a child theme or a parent theme and then use it to load in the included php files which you place in an 'includes' directory in your theme's root;

In functions.php;

if ( STYLESHEETPATH == TEMPLATEPATH ) {
define('OF_FILEPATH', TEMPLATEPATH);
} else {
define('OF_FILEPATH', STYLESHEETPATH);
}

require_once (OF_FILEPATH . '/includes/search.php');        
require_once (OF_FILEPATH . '/includes/query.php');
require_once (OF_FILEPATH . '/includes/vcard.php');

That should work for you.

Sign up to request clarification or add additional context in comments.

5 Comments

Looks like the theme's author has defined 'TEMPLATEPATH'. So I did-> require_once(TEMPLATEPATH . '/engine/engine.php'); require_once (TEMPLATEPATH . '/includes/search.php'); require_once (TEMPLATEPATH . '/includes/query.php'); require_once (TEMPLATEPATH . '/includes/vcard.php'); still gives me a 'no such file or directory' but the folder is there ?
Hmm - echo out TEMPLATEPATH to see if it gives the correct path.
Is there any whitespace after your closing ?> tags, try including the fIles one at a time in case theres an error in one of them. Add a file with a hello world function in it to see if it's loading that file and can access that function.
Now I see. functions.php can find those files. (no errors) but my JS file when posting data to query.php is not. How can I make my .js file post it's data to these files?
Good, glad to hear that at least your custom files are being loaded. This one is sorted, the JS issue should be another question altogether. Post another question with the code in it - your js, how you are trying to post data, what you are trying to do with it etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.