我需要将自定义选项添加到wp_dropdown_categories
. 现在,整个万维网世界还没有找到解决方案。。。因此,我在这里要求一个解决方案……因为我真的无法想象WordPress的开发人员没有考虑到这将永远不需要,对吗?
如何将自定义选项添加到wp_Dropdown_Categories?
1 个回复
SO网友:Bikash Waiba
你可以这样做
add_filter( \'wp_dropdown_cats\', \'add_yet_another_option\', 10, 2 );
function add_yet_another_option( $output, $r ){
$output = str_replace( \'</select>\',\'\',$output ); // remove closing select tag
$output .= \'<option class="level-0" value="some-value"> Some Custom Options </option>\'; // custom option.
$output .= \'</select>\'; // add closing select tag
return $output;
}
但为什么会有人把自定义选项放在类别下拉列表中?结束