问题描述
我需要在 Wordpress 中包含一个自定义的 PHP 页面.
I need to include a custom PHP page in Wordpress.
所以我需要做的就是使用安装在该 Wordpress 上的 Wordpress 主题来显示这个自定义 php 页面.
So what I need to do is just to show this custom php page using the Wordpress theme installed on that Wordpress.
不介意使用哪个主题,自定义 php 页面必须显示在任何安装的主题下.
Does not mind which theme is up, the custom php page will have to be shown under any theme is installed in that moment.
如何在 Wordpress 中执行此操作?
How do I do it in Wordpress?
我是 Wordpress 开发的新手.
I am new to Wordpress development.
谢谢
推荐答案
创建一个可以在任何主题中查看(并应用主题)的自定义 php 页面将相当困难.
Creating a custom php page that will be able to be viewed in any theme (and have the theme applied) would be considerably difficult.
每个 wordpress 页面调用该特定主题的特定主题函数,以及引用该主题的文件以生成页眉、页脚、css 文件、javascript 文件等.您的自定义页面需要针对所有这些意外情况进行计划, 对于使用的每个可能的主题.
Each wordpress page calls specific theme functions of that particular theme, as well as referencing files of that theme to generate header, footer, css files, javascript files, etc.. Your custom page would need to plan for all of these contingencies, for each possible theme used.
这是一个替代解决方案:通过此插件
Here's a alternative solution: inject PHP code directly into a standard wordpress page via this plugin http://wordpress.org/extend/plugins/allow-php-in-posts-and-pages/
含义:您制作了一个普通的 wordpress 页面,但可以向其中添加 php.呈现此页面时,将使用正确的页面模板,并为您处理所有主题引用.
Meaning: you make a normal wordpress page, but are able to add php to it. When this page is rendered, the proper page template is used, and all the theme references are taken care of for you.
这篇关于在自定义 php 页面中包含 wordpress 主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!