add_filter 函数在 wordpress 中没有被调用
add_filter function not getting called in wordpress
我在 wordpress 文件中创建了一个 custom_post_type。但是我在添加过滤功能时遇到了麻烦。过滤功能好像没有被唤起? alpha_set_contact_coloumns() 没有提供任何结果。
<?php
$contact = get_option( 'activate_contact' );
if(@$contact == 1){
add_action( 'init', 'alpha_contact_custom_post_type' );
add_filter( 'manage_alpha-contact_posts_coloumns', 'alpha_set_contact_coloumns' );
}
function alpha_contact_custom_post_type() {
$labels = array(
'name' => 'Messages',
'singular_name' => 'Message',
'menu_name' => 'Messages',
'name_admin_bar'=> 'Message'
);
$args = array(
'labels' => $labels,
'show_ui' => true,
'show_in_menu' => true,
'capability_type'=> 'post',
'hierarchical' => false,
'menu_position' => 26,
'menu_icon' => 'dashicons-email-alt',
'supports' => array('title', 'editor', 'author')
);
register_post_type( 'alpha-contact', $args );
}
function alpha_set_contact_coloumns( $coloumns ) {
unset( $coloumns['author']);
return $coloumns;
}
试试这个代码。
代码中存在拼写错误。我用 manage_alpha-contact_posts_columns
.
替换了这段代码 manage_contact_posts_coloumns
它是列而不是coloumns
。
$contact = get_option( 'activate_contact' );
if(@$contact == 1){
add_action( 'init', 'alpha_contact_custom_post_type' );
add_filter( 'manage_alpha-contact_posts_columns', 'alpha_set_contact_coloumns' );
}
function alpha_contact_custom_post_type() {
$labels = array(
'name' => 'Messages',
'singular_name' => 'Message',
'menu_name' => 'Messages',
'name_admin_bar'=> 'Message'
);
$args = array(
'labels' => $labels,
'show_ui' => true,
'show_in_menu' => true,
'capability_type'=> 'post',
'hierarchical' => false,
'menu_position' => 26,
'menu_icon' => 'dashicons-email-alt',
'supports' => array('title', 'editor', 'author')
);
register_post_type( 'alpha-contact', $args );
}
function alpha_set_contact_coloumns( $coloumns ) {
unset( $coloumns['author']);
return $coloumns;
}
我在 wordpress 文件中创建了一个 custom_post_type。但是我在添加过滤功能时遇到了麻烦。过滤功能好像没有被唤起? alpha_set_contact_coloumns() 没有提供任何结果。
<?php
$contact = get_option( 'activate_contact' );
if(@$contact == 1){
add_action( 'init', 'alpha_contact_custom_post_type' );
add_filter( 'manage_alpha-contact_posts_coloumns', 'alpha_set_contact_coloumns' );
}
function alpha_contact_custom_post_type() {
$labels = array(
'name' => 'Messages',
'singular_name' => 'Message',
'menu_name' => 'Messages',
'name_admin_bar'=> 'Message'
);
$args = array(
'labels' => $labels,
'show_ui' => true,
'show_in_menu' => true,
'capability_type'=> 'post',
'hierarchical' => false,
'menu_position' => 26,
'menu_icon' => 'dashicons-email-alt',
'supports' => array('title', 'editor', 'author')
);
register_post_type( 'alpha-contact', $args );
}
function alpha_set_contact_coloumns( $coloumns ) {
unset( $coloumns['author']);
return $coloumns;
}
试试这个代码。
代码中存在拼写错误。我用 manage_alpha-contact_posts_columns
.
manage_contact_posts_coloumns
它是列而不是coloumns
。
$contact = get_option( 'activate_contact' );
if(@$contact == 1){
add_action( 'init', 'alpha_contact_custom_post_type' );
add_filter( 'manage_alpha-contact_posts_columns', 'alpha_set_contact_coloumns' );
}
function alpha_contact_custom_post_type() {
$labels = array(
'name' => 'Messages',
'singular_name' => 'Message',
'menu_name' => 'Messages',
'name_admin_bar'=> 'Message'
);
$args = array(
'labels' => $labels,
'show_ui' => true,
'show_in_menu' => true,
'capability_type'=> 'post',
'hierarchical' => false,
'menu_position' => 26,
'menu_icon' => 'dashicons-email-alt',
'supports' => array('title', 'editor', 'author')
);
register_post_type( 'alpha-contact', $args );
}
function alpha_set_contact_coloumns( $coloumns ) {
unset( $coloumns['author']);
return $coloumns;
}