In my themes exist plugin how registering 10 custom post type with add_action( 'after_setup_theme', 'like_add_custom_post_types' );I want change it and registr only 2.
I try remove this with remove_action() and writh new action, but have errors, Fatal error: Cannot redeclare like_add_custom_post_types() (previously declared in ....(plugin path) //////this plugin code
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' );