我正在尝试在这个包装好的短代码中加载这个php函数,但它不起作用。任何帮助都会很棒。谢谢!
<?php
$my_tabs = '
[accordions title="" disabled="false" active="false" autoheight="false" collapsible="true"]
[accordion title="SPECIFICATIONS"] ' . if( function_exists( 'wpsc_the_custom_fields' ) ) wpsc_the_custom_fields() . ' [/accordion]
[/accordions] ';
echo do_shortcode( $my_tabs );
?>
答案 0 :(得分:1)
使用名为Ternary operator
http://en.wikipedia.org/wiki/%3F的快捷条件符号
<?php
$my_tabs = '
[accordions title="" disabled="false" active="false" autoheight="false" collapsible="true"]
[accordion title="SPECIFICATIONS"] ' . ( function_exists( 'wpsc_the_custom_fields' ) ) ? wpsc_the_custom_fields() : '' . ' [/accordion]
[/accordions] ';
echo do_shortcode( $my_tabs );
&GT;
答案 1 :(得分:1)
<?php
$my_tabs = '
[accordions title="" disabled="false" active="false" autoheight="false" collapsible="true"]
[accordion title="SPECIFICATIONS"] ' . (function_exists( 'wpsc_the_custom_fields' ) ? wpsc_the_custom_fields() : '') . ' [/accordion]
[/accordions] ';
echo do_shortcode( $my_tabs );
?>