开发者

Re-use a section of PHP code in multiple PHP files

开发者 https://www.devze.com 2023-01-14 01:08 出处:网络
I have a section of PHP code that I would like to place in a direc开发者_开发百科tory somewhere and then within my custom WordPress page templates, make reference to this code library at a specific po

I have a section of PHP code that I would like to place in a direc开发者_开发百科tory somewhere and then within my custom WordPress page templates, make reference to this code library at a specific point in my page template.

Can I create my own WordPress hook to grab this code and place it where I want it used?


in your wordpress templates you can use php code. therefore just do an

<?php include("somefile.php"); ?>


You could include all those functions into the functions.php of your theme or you can move them into some external PHP file and include it with include() or require() within your functions.php file.

0

精彩评论

暂无评论...
验证码 换一张
取 消