Calling a function in a custom php template in Wordpress

前提是你 提交于 2020-02-02 19:57:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!