我设法解决了这个问题。似乎只有在包装为“admin\\u init”操作时,过滤器才起作用。我的最后一段代码,用于将自定义分类法元“front\\u page”的管理列添加到My themes函数中的自定义分类法“shopp\\u department”。php
// Register the column
function department_add_dynamic_hooks() {
$taxonomy = \'shopp_department\';
add_filter( \'manage_\' . $taxonomy . \'_custom_column\', \'department_taxonomy_rows\',15, 3 );
add_filter( \'manage_edit-\' . $taxonomy . \'_columns\', \'department_taxonomy_columns\' );
}
add_action( \'admin_init\', \'department_add_dynamic_hooks\' );
function department_taxonomy_columns( $original_columns ) {
$new_columns = $original_columns;
array_splice( $new_columns, 1 );
$new_columns[\'frontpage\'] = esc_html__( \'Front Page\', \'taxonomy-images\' );
return array_merge( $new_columns, $original_columns );
}
function department_taxonomy_rows( $row, $column_name, $term_id ) {
$t_id = $term_id;
$meta = get_option( "taxonomy_$t_id" );
if ( \'frontpage\' === $column_name ) {
if ($meta == true) {
return $row . \'Yes\';
} else {
return $row . \'No\';
}
}
希望这对别人有帮助。