开发者

WordPress - PHP Code Box

开发者 https://www.devze.com 2023-01-10 22:25 出处:网络
I am very new to WordPress, so I would appreciate some help. I am using WordPress as a CMS, and I am trying to make the thing work so that when I select a page to edit, there is a special box where I

I am very new to WordPress, so I would appreciate some help.

I am using WordPress as a CMS, and I am trying to make the thing work so that when I select a page to edit, there is a special box where I can input PHP code that will execute on my page.

I have found the PHP exec plugin, which works perfectly, but I would like to keep the code out of my main text editor, out of the way of my client's careless fingers.

Any suggestions wo开发者_开发技巧uld be very, very appreciated. Thanks!


You could create a template for each one, and include your PHP there.

Simply select the template from the page edit page.

But if you are only including a little PHP per page, you could get the slug via WordPress in your page template and act on it accordingly.


You can also add an extra meta box on the post editor page, only visible to you, with a textarea where you can add the code. You would save it as a meta field of the post. Your template can check for the existence of this field, and execute it if found.


PHP Exec is the best plugin I have found, and I looked long and hard for that one. The problem with doing it as you suggest is that if the PHP code displays an item on the page, it still has to be formatted within the page as well. It is a simple logistical problem, but somewhat of a complex coding problem. I haven't been able to get around to working on creating a better plugin for it.

0

精彩评论

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

关注公众号