[shortcode]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[/shortcode]
根据对短代码的需要,需要根据用户/管理员输入重复HTML部分。我提出了一种格式。以上是可能的吗?
短代码是否可以在短代码中多次发布?
<小时>Further explanation of the situation 未来的读者可能会发现它很有用→ 这是HTML的大厦(Hypothetical example)
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<p>Answer</p>
</li>
</ul>
</div>
</div>
</div>
这部分是重复的和内部的短代码→
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<h3>Question</h3>
</li>
我认为外部短代码的代码将这样编写→
function external_shortcode(){
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<!-- This is the place where I want the inner shortcode many time -->
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
}
add_shortcode( \'shortcode\', \'external_shortcode\' );
内部短代码的代码→
function internal_shortcode($atts, $content = null){
$data = [
\'title\' => \'Some heading text goes here.\',
];
$values = shortcode_atts($data, $atts);
ob_start();
?>
<li class="question">
<h3><?php echo esc_attr($values[\'title\']); ?></h3>
</li>
<li class="answer">
<p><?php echo $content; ?></p>
</li>
<?php
return ob_get_clean();
}
add_shortcode( \'shortcode1\', \'internal_shortcode\' );