1

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' );
Artak
  • 11
  • 3

1 Answers1

0

Search function called like_add_custom_post_types in theme. Given error says function with name like_add_custom_post_types is already in theme.

How to solve :

  • change a function name to something else.
  • If you want to remove 8 post type then find function and comment register_post_type

    add_action( 'after_setup_theme', 'like_add_custom_post_types' );

Vasim Shaikh
  • 4,485
  • 2
  • 23
  • 52