Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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 如何拆分$content以接收<;h2>;及<;p>;在Wordpress中创建短代码时?_Php_Wordpress_Shortcode - Fatal编程技术网

Php 如何拆分$content以接收<;h2>;及<;p>;在Wordpress中创建短代码时?

Php 如何拆分$content以接收<;h2>;及<;p>;在Wordpress中创建短代码时?,php,wordpress,shortcode,Php,Wordpress,Shortcode,更改主题后,在许多文章中,我都有一个旧的短代码。它包括和。我想用相同的名称创建一个新的短代码,以便重新设置旧的短代码的样式。对于和我需要不同的类 我有这个功能: function factoid_function( $atts, $content = null ) { return '<div class="vf-box vf-box--normal vf-box-theme--primary | factoid-box">' . '<p class="vf-box__

更改主题后,在许多文章中,我都有一个旧的短代码。它包括
。我想用相同的名称创建一个新的短代码,以便重新设置旧的短代码的样式。对于
我需要不同的类

我有这个功能:

function factoid_function( $atts, $content = null ) {
    return '<div class="vf-box vf-box--normal vf-box-theme--primary | factoid-box">' . '<p class="vf-box__text">' . $content . '</p>' . '</div>';
}
add_shortcode('fact-box', 'factoid_function');
函数factoid\u函数($atts,$content=null){
返回“.”.$content.“

”; } 添加_短代码(“事实框”、“factoid_函数”);
这是HTML输出

<div class="vf-box vf-box--normal vf-box-theme--primary | factoid-box">
<p class="vf-box__text"></p>
<h2>What is mesoscopic imaging?</h2>
<p>Mesoscopic imaging involves looking at details of biological systems in the context of an organ, body part, or organism. It’s an approach that recognises that a heart, an arm, or a fish is more than just a set of cells. In any tissue, organ, or body part, cells are packed tightly together or arranged in relation to each other.
</p>
</div>

什么是介观成像? 介观成像涉及在器官、身体部位或生物体的背景下观察生物系统的细节。这是一种认识到心脏、手臂或鱼不仅仅是一组细胞的方法。在任何组织、器官或身体部位,细胞紧密地聚集在一起或相互联系。

为什么$content被抛出类的段落之外

如何拆分$content,以便为段落分配
vf-box\u文本
,为h2分配
vf-box\u标题


提前谢谢

您必须对内容进行快捷编码。并使用编辑器制作您的
。将它们放在
[fact box]
[/fact box]

函数factoid\u函数($atts,$content=null){
$output='

; $output.=do_短代码($content); $output.='

'; 返回$output; } 添加_短代码(“事实框”、“factoid_函数”);
您必须对内容进行快捷编码。并使用编辑器制作您的
。将它们放在
[fact box]
[/fact box]

函数factoid\u函数($atts,$content=null){
$output='

; $output.=do_短代码($content); $output.='

'; 返回$output; } 添加_短代码(“事实框”、“factoid_函数”);