Wordpress Text Widget用html注释标签替换php标签? [英] Wordpress Text Widget replaces php tags with html comment tags?

查看:105
本文介绍了Wordpress Text Widget用html注释标签替换php标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的小型mce编辑器的代码编辑器部分的wordpress网站上的页面上添加一些php。但是,只要键入以下内容:

I am attempting to add some php to a page on my wordpress site in the code editor part of my tiny mce editor. However, whenever type something like:

<?php echo "Hello World"; ?>

然后保存文章,当我下次去编辑文章时,它将php标签替换为html注释:

and then save the article, when I next go to edit the article it replaces my php tags with a html comment:

<!--?php echo "Hello World"; ?-->

如果有人知道这里发生了什么以及WordPress为什么这样做,将不胜感激。

Would be very grateful if anyone knows what is going on here and why WordPress is doing this.

推荐答案

要在内容编辑器中使用PHP代码,您将需要安装允许您执行此操作的插件,或者创建一个

To use PHP code in your content editor, you will either need to install a plugin that allows you to do this, or create a shortcode.

要在functions.php中创建简码:

To create a shortcode in functions.php:

<?php
function hello_shortcode() {
    echo 'Hello world!';
}
add_shortcode('hello', 'hello_shortcode');
?>

然后在内容编辑器中,放入:

Then in the content editor, put:

[hello]

希望这会有所帮助。

这篇关于Wordpress Text Widget用html注释标签替换php标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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