插件代码
function myShortcode( $atts ) {
extract( shortcode_atts( array( 'cat' => '', ), $atts ) );
ob_start();
if ( $cat == '' ) { echo "Do Nothing!"; }
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;
}
add_shortcode( mycatlist, myShortcode);
在帖子中添加以下短代码(在 wp-admin 的帖子部分中)
[mycatlist cat=4]
在 wordpress 模板文件中添加以下代码
<?php echo do_shortcode("[mycatlist]"); ?>
我得到那个输出什么都不做!
但我想得到 cat 值,我的意思是 4