一些任意/假设的简码示例→
function simplisto_some_function(){
ob_start();
?>
<div class="newsletter class2">
<h2><?php echo get_theme_mod('kirki_h'); ?></h2>
<p><?php echo get_theme_mod('kirki_p'); ?></p>
</div>
//Some Other code
<?php
return ob_get_clean();
}
add_shortcode('simplisto_some_function', 'simplisto_some_function');
我的简码要求→
[simplisto_some_function]
我应该有以下选择:
选项是否选择/使用” class2″选项消除<h2>选项消除<p>
附言→默认情况下, 选择了<h2>和<p>。
这可能还是这不是现实的期望?
#1
你可以将选项从简码传递给函数…
简码
[simplisto useClass="1" useH2="0" useP="1"]
然后功能
function simplisto_function($atts){
extract( shortcode_atts( array(
'useClass' => '', 'useH2' => 1, 'useP' => 1
), $atts ) );
$args = array(
'useClass' => $useClass, 'useH2' => $useh2, 'useP' => $usep
);
ob_start();
//use your conditions in the html code
?>
<div class="newsletter<?php $useClass==1 ? echo ' class2' : '' ?>">
//the same for others
</div>
//Some Other code
<?php
return ob_get_clean();
}
add_shortcode('simplisto', 'simplisto_function');
评论前必须登录!
注册