简体   繁体   English

在WordPress页面上调用PHP文件

[英]Calling php file on wordpress page

I have a php file which contains functions that connects with API. 我有一个PHP文件,其中包含与API连接的函数。 Functions in that file work correctly when tested from another php file. 从另一个PHP文件进行测试时,该文件中的功能可以正常工作。 Website that should call this functions is written using wordpress. 应使用wordpress编写应调用此功能的网站。 Since I'm not familiar with wordpress, how could I call them? 由于我对wordpress不熟悉,我怎么称呼它们? For example: Website have login form which contains one button. 例如:网站有一个包含一个按钮的登录表单。 On button click I also have to call my function which is implemented in external (self written) php file. 在单击按钮时,我还必须调用在外部(自写)php文件中实现的函数。 I do know that button click is on client side and php is on server side. 我确实知道按钮单击位于客户端,而php位于服务器端。 What bugs me is that when I saw source code of website I've seen that all pages are written in php but I can't navigate through them. 让我感到烦恼的是,当我看到网站的源代码时,我已经看到所有页面都是用php编写的,但我无法浏览它们。 What would be the easyest way to call this function on those button clicks? 在这些按钮单击时调用此函数的最简单方法是什么?

You can include file like this: 您可以包含以下文件:

you can load this file in current theme function.php 您可以在current theme function.php加载此文件

get_template_part('filename');

filename means your php file name. filename是您的php文件名。

add php file in your theme file. 在主题文件中添加php文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM