• I have a very basic, very confused question:

    if I do this in the parent theme’s functions.php:

    function some_action(){
        do_action('some_action');
    }
    
    function print_hello(){
       echo "hello"
    }
    
    add_action('some_action','print_hello');
    
    some_action();
    
    //echos hello

    That’s all fine and dandy. But if in the child theme’s functions.php I do:

    require_once(TEMPLATEPATH . '/functions.php');
    var_dump(remove_action('some_action', 'print_hello')); exit;

    I get

    bool(false)

    Why?

    I recently wrote a test:

    if(has_action('some_action', 'print_hello')){
    		echo "true";
    	}else{
    		echo "action deos not exist";
    	}

    and got:

    action deos not exist

Viewing 1 replies (of 1 total)
  • you need to add a hook to “after_setup_theme”

    ie:

    function demo_after_setup () {
    
    if(has_action('some_action', 'print_hello')){
    		echo "true";
    	}else{
    		echo "action deos not exist";
    	}
    }
    add_action('after_setup_theme', 'demo_after_setup");

    get rid of the REQUIRE_ONCE. That’s not necessary after you add this hook, as WordPress as already done the require.

Viewing 1 replies (of 1 total)
  • The topic ‘removing an action in the child theme’ is closed to new replies.