-2

我试图在这个包装的短代码中加载这个 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 );
?>
4

2 回答 2

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 );

?>

于 2013-08-01T07:18:02.537 回答
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 );
?>
于 2013-08-01T07:18:08.690 回答