在我的主题存在插件如何注册10个自定义后类型与ADD_ACTION(“after_setup_theme”,“like_add_custom_post_types”);我想改变它,registr只有2。
我尝试用remove_action删除此()和writh新的行动,但有错误,致命错误:不能重新声明like_add_custom_post_types()(以前在...(插件路径声明)//////这个插件代码
function like_add_custom_post_types() {
$cpt = array(
'testimonials' => true,
'sliders' => true,
'sections' => true,
'events' => true,
'menu' => true,
'gallery' => true,
'team' => true,
'faq' => true,
);
foreach ($cpt as $item => $enabled) {
$cpt_include = likeGetLocalPath( '/post_types/' . $item . '/' . $item . '.php' );
if ( $enabled AND file_exists( $cpt_include ) ) {
include_once $cpt_include;
}
}
}
add_action( 'after_setup_theme', 'like_add_custom_post_types' );
function like_rewrite_flush() {
like_add_custom_post_types();
flush_rewrite_rules();
}
///////// my code
add_action( 'after_setup_theme', 'remove_parent_theme_stuff', 0 );
function remove_parent_theme_stuff() {
remove_action( 'after_setup_theme', 'like_add_custom_post_types' );
}
add_action('after_setup_theme',"like_add_custom_post_types");
function like_add_custom_post_types() {
include_once ABSPATH.'/wp-content/plugins/like-themes-plugins/post_types/sections/sections.php';
}
add_action( 'after_setup_theme', 'like_add_custom_post_types' );
在主题叫like_add_custom_post_types
搜索功能。由于错误地说名字like_add_custom_post_types
功能已经在主题。
怎么解决 :
register_post_type
ADD_ACTION( 'after_setup_theme', 'like_add_custom_post_types');