如何在 Wordpress 主题中加载自定义 php 文件 [英] How to load custom php file in Wordpress themes

查看:43
本文介绍了如何在 Wordpress 主题中加载自定义 php 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建了一个使用 wordpress 和自定义主题的网站.这是我的主题目录

/themes/customtheme/-index.php-header.php-footer.php-blog.php....

index.php 包括headerfooter、显示在我网站上的信息以及指向我的博客页面的链接.>

博客文件看起来和普通博客网站一样.

我可以知道如何在主题目录下的index.php 中写一个超链接(a href),以便在点击时提示blog.php?

解决方案

如果我很清楚您的问题,您需要使用您的 blog.php 文件创建一个新的页面模板.只需在文件开头添加以下代码:

然后在backed中创建一个新页面并将其关联到新创建的模板.

此处阅读有关页面模板的更多信息.

I've just created a website using wordpress and a custom theme for it. This is my theme directory

/themes/customtheme/
 -index.php
 -header.php
 -footer.php
 -blog.php
 ....

The index.php includes header,footer,information to shown on my website, and a link to my blog page.

Blog file will looks same as normal blog site.

May i know how to write a hyperlink(a href) in index.php under theme directory so that it can prompt to the blog.php when click?

解决方案

If I understand well your question you need to create a new page template using your blog.php file. Just add the following code at the beginning of the file:

<?php
/*
Template Name: My Blog Page
*/

And then create in the backed a new page and associate it to the newly created template.

Read more about page templates here.

这篇关于如何在 Wordpress 主题中加载自定义 php 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆