Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP函数在使用HTMl标记传递内容时遇到问题_Php_Html_Wordpress - Fatal编程技术网

PHP函数在使用HTMl标记传递内容时遇到问题

PHP函数在使用HTMl标记传递内容时遇到问题,php,html,wordpress,Php,Html,Wordpress,在我的主题的functions.php文件中,我有一个字符串,它生成周围的HTML并通过get\u the\u content()函数获取内容 问题是,如果通过该函数传递的内容具有html标记,它会将其打断,并将内容放入自己的div中 因此,如果传递的内容是像“this is text”这样的纯文本,那么它将生成 <div class='col-md-4 my-2'> <div class='coupon-container shadow' style='backgro

在我的主题的functions.php文件中,我有一个字符串,它生成周围的HTML并通过
get\u the\u content()
函数获取内容

问题是,如果通过该函数传递的内容具有html标记,它会将其打断,并将内容放入自己的div中

因此,如果传递的内容是像“this is text”这样的纯文本,那么它将生成

<div class='col-md-4 my-2'>
    <div class='coupon-container shadow' style='background: url(". $thumbnail . "); background-size:cover; background-position:center;'> 
        <div class='coupon-content'>
            <p class='coupon-title font-weight-bold'>Title</p>
            <p class='coupon-desc' id='coupon-description'>This is text</p>
            <a class='coupon-link' href=". get_the_permalink() .">Open in new tab</a>
        </div>
    </div>
</div>

标题

这是文本

但是,如果内容作为
传入,则
我如何才能做到即使是通过现有html标记传入的内容也能放入优惠券描述部分?

2种方式:

摆脱

或用块元素替换

段落元素不能嵌套,浏览器将假定您正在尝试创建新段落。但是,您可以使用诸如div之类的元素将内容保留在HTML中,但仍然可以对div应用样式等

通过PHP函数传递它,以去除所有HTML


通过传递数据,这将删除所有HTML标记,只返回纯文本字符串。

很棒的调用,我将类从更改为,看起来已经修复了它!我完全忽略了嵌套段落标签的能力,谢谢你的帮助!请分享更多详细信息,如相关代码。目前,我在你的问题中没有看到PHP代码
<div class='col-md-4 my-2'>
    <div class='coupon-container shadow' style='background: url(". $thumbnail . "); background-size:cover; background-position:center;'>
        <div class='coupon-content'>
            <p class='coupon-title font-weight-bold'>Title</p>
            <p class='coupon-desc' id='coupon-description'></p>
            <p>this is <a>text</a></p>
            <a class='coupon-link' href=". get_the_permalink() .">Open in new tab</a>
        </div>
    </div>
</div>