dougu4704 2015-10-05 21:35
浏览 85
已采纳

如何在Wordpress中创建自定义页面

Hi I'd like to create a totally custom page in wordpress where I'd add a lot of php code so I would prefer not to create it as a wordpress 'Page', but as a file 'filename.php' in my theme directory. Of course in that page I need to include wp functions and stuff and I plan to do it with require_once("../../../../wp-load.php");.

My problem is, how do I set the header info for a custom page like that (title, meta description etc..) and how do I add a rewrite rule to make it reachable like "website.dom/pagename". Thanks in advance for any answer, and even if you tell me that the best way is to use wordpress default "Add New Page", I'd prefer not to use any script to insert php code in the page, thanks.

  • 写回答

2条回答 默认 最新

  • donoworuq450547191 2015-10-05 21:42
    关注

    WordPress has built in functionality to look for custom pages, and does so every time you open up a page. To have WordPress find it you could for instance name the file page-{id}.php or page-{slug}.php and place it in your theme folder. So if the name of your page i "about" - which you create as you usually would, using the admin section in WordPress - you name your file "page-about.php". WordPress will then automatically load it.

    To load the title of your page, use get_header( 'about' ); (Although, that's part of the header).

    A good way to start would be to locate page.php, holding the default template, copy it and rename it as explained above. Then edit it in any way you want. You'll find a good guide here.

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

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么