How to load custom php file in Wordpress themes

♀尐吖头ヾ 提交于 2019-12-25 10:19:17

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/29250885/how-to-load-custom-php-file-in-wordpress-themes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!