dongxi8297 2010-05-11 11:12
浏览 28
已采纳

如何将PHP页面添加到WordPress?

I want to create a custom page for my WordPress blog that will execute my PHP code in it, whilst remaining a part of the overall site CSS/theme/design.

The PHP code will make use of 3rd party APIs (so I need to include other PHP files)

How do I accomplish this?

N.B. I do not have a specific need to interact with the Wordpress API - apart from including certain other PHP libs I need I have no other dependencies in the PHP code I want to include in a WP page. So obviously any solution that didn't require learning the WP API would be the best one.

  • 写回答

18条回答 默认 最新

  • dongsuiying7773 2010-05-11 12:42
    关注

    You don't need to interact with the API or use a plugin.

    First, duplicate post.php or page.php in your theme folder (under /wp-content/themes/themename/).

    Rename the new file as templatename.php (where templatename is what you want to call your new template). To add your new template to the list of available templates, enter the following at the top of the new file:

    <?php
    /*
    Template Name: Name of Template
    */
    ?>
    

    You can modify this file (using PHP) to include other files or whatever you need.

    Then create a new page in your WordPress blog, and in the page editing screen you'll see a Template dropdown in the Attributes widget to the right. Select your new template and publish the page.

    Your new page will use the PHP code defined in templatename.php

    Source: https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-page-templates-for-global-use

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(17条)

报告相同问题?

悬赏问题

  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件