问题
I want to call a function which is in another php class that I wrote in Wordpress. However I'm confused about the syntax, e.g. to get the header on a page you just call get_header(); etc. But how do i call a function in a specific class? For example in index.php I want to call a function named this_function() which reside in say test.php. What is the syntax for this?
I suspect it to be very simple, but I can't get the syntax right, and I can't any help online.
Thanks
回答1:
First use require_once()
to include the test.php, i.e.
require_once("path\test.php");
Then you can simply call this-function()
and it will work.
You can use this as reference : http://www.php.net/manual/en/function.require.php
来源:https://stackoverflow.com/questions/11192907/calling-a-function-in-a-custom-php-template-in-wordpress