热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

wordpress允许投稿_如何在WordPress帖子和页面中允许PHP

wordpress允许投稿Bydefault,youcannotexecutePHPinWordPresspostsandpages.Wehavemadeitaruleofthum

wordpress允许投稿

By default, you cannot execute PHP in WordPress posts and pages. We have made it a rule of thumb to never execute PHP in our posts and pages either because it can be hectic to change things in the future. A better practice would be to edit the WordPress theme by creating a custom page template, or single post template. However for some users, it may be necessary to execute PHP in WordPress posts. We couldn’t find a need for it, but apparently over 26,000 people have. So in this article, we will share how to allow PHP in WordPress posts and pages.

默认情况下,您无法在WordPress帖子和页面中执行PHP。 根据经验,永远不要在我们的帖子和页面中执行PHP,因为将来可能会忙于更改。 更好的做法是通过创建自定义页面模板或单个帖子模板来编辑WordPress主题。 但是,对于某些用户,可能有必要在WordPress帖子中执行PHP。 我们找不到它的需要,但显然有26,000多人需要它。 因此,在本文中,我们将分享如何在WordPress帖子和页面中允许PHP。

Simply install and activate the plugin Allow PHP in Posts and Pages. After installation, simply wrap your php queries inside the shortcode:

只需安装并激活插件Allow PHP in Posts and Pages即可 。 安装后,只需将您的php查询包装在简码内:

[ php] [ /php] – Please ignore the spaces. We cannot use this shortcode because it will pull our Syntax Highlighter Evolved plugin.

[php] [/ php] –请忽略空格。 我们不能使用此短代码,因为它会拉出我们的Syntax Highlighter Evolved插件。

You can also save your php queries and call them on post or pages when you need them. To do this, simply click on Allow PHP in Posts menu option. Click on the Code Snippets Tab. Add your PHP query there.

您还可以保存您的php查询,并在需要时在帖子或页面上调用它们。 为此,只需单击“允许Posts中PHP”菜单选项。 单击“代码片段”选项卡。 在此处添加您PHP查询。

Allow PHP in Posts and Pages

Then in your post, simply use the shortcode with the Snippet ID:

然后在您的帖子中,只需使用带有代码段ID的简码即可:

[ php function=ID]

[php function = ID]

Get Allow PHP in Posts and Pages

在帖子和页面中获取允许PHP

翻译自: https://www.wpbeginner.com/plugins/how-to-allow-php-in-wordpress-posts-and-pages/

wordpress允许投稿



推荐阅读
author-avatar
mobiledu2502870687
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有