Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.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/11.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/0/backbone.js/2.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
Html 如何在打开和关闭的短代码之间放置多行代码_Html_Wordpress_Woocommerce_Shortcode - Fatal编程技术网

Html 如何在打开和关闭的短代码之间放置多行代码

Html 如何在打开和关闭的短代码之间放置多行代码,html,wordpress,woocommerce,shortcode,Html,Wordpress,Woocommerce,Shortcode,我试图在一个自定义html页面模板中,在一个限制内容的短代码之间添加多行代码 简称: <?php echo do_shortcode("[wcm_restrict plans="gold, platinum"]Restricted Content[/wcm_restrict]"); ?> 我尝试过将代码放在下面这样的短代码中,但没有成功: <?php echo do_shortcode("[wcm_restrict plans="gold, platinum"]");

我试图在一个自定义html页面模板中,在一个限制内容的短代码之间添加多行代码

简称:

<?php echo do_shortcode("[wcm_restrict plans="gold, platinum"]Restricted Content[/wcm_restrict]"); ?> 

我尝试过将代码放在下面这样的短代码中,但没有成功:

<?php echo do_shortcode("[wcm_restrict plans="gold, platinum"]"); ?>
    <h1>This is a Heading for demo display</h1>
    <p>This is a demo paragraph.</p>
    <?php echo do_shortcode("[/wcm_restrict]"); ?>

这是演示显示的标题
这是一个演示段落

在短代码之间放置多行代码的正确方法是什么

<?php echo do_shortcode("[wcm_restrict plans="gold, platinum"]Multiple lines of code here[/wcm_restrict]"); ?>

第一种方法的问题是,您的内容在短代码之外,并且插入了两个短代码

尝试类似的方法并让我们知道:

<?php

$content = '[wcm_restrict plans=\"gold, platinum\"]
    <h1>This is a Heading for demo display</h1>
    <p>This is a demo paragraph.</p>[/wcm_restrict]';

echo do_shortcode("$content"); ?>


编辑:正如双引号所指出的,需要转义。答案已更新以反映这一变化。

您好,谢谢Lucas,没有错误,但它没有显示任何内容。我确实在结尾添加了一个结束标记“>”,我甚至删除了短代码“[wcm_restrict]”,并且它没有显示任何内容。在使用了您的代码后,如果您这样说,我们可以让它正常工作,请更新您的答案,我可以将您的答案标记为最终答案,谢谢您的帮助