我最近发现,我们可以插入如下类别的下拉列表:
define( \'WP_USE_THEMES\', false );
require( \'./wp-load.php\' );
wp_dropdown_categories( array(
\'child_of\' => 0,
\'class\' => \'postform\',
\'depth\' => 0,
\'echo\' => 1,
\'exclude\' => \'\',
\'hide_empty\' => false,
\'hide_if_empty\' => false,
\'hierarchical\' => true,
\'id\' => \'\',
\'name\' => \'cat-dropdown\',
\'order\' => \'ASC\',
\'orderby\' => \'name\',
\'selected\' => 0,
\'show_count\' => 0,
\'show_option_all\' => \'\',
\'show_option_none\' => __(\'None\'),
\'tab_index\' => 0,
\'taxonomy\' => \'format\',
) );
这很好,但是如果我想选择多个类别呢?我遇到过wp_category_checklist()
并尝试了以下代码:
function wp_category_checklist(
$post_id = 0,
$descendants_and_self = 0,
$selected_cats = false,
$popular_cats = false,
$walker = null,
$checked_ontop = true
) {
wp_terms_checklist( $post_id, array(
\'taxonomy\' => \'category\',
\'descendants_and_self\' => $descendants_and_self,
\'selected_cats\' => $selected_cats,
\'popular_cats\' => $popular_cats,
\'walker\' => $walker,
\'checked_ontop\' => $checked_ontop
) );
}
但它没有输出任何东西。我试图在空白页上获得我的类别列表,而不是在侧边栏或帖子中。这可能吗?