add_action works outside condition but not inside it


I am developing a theme framework for my own purposes.

So this time i am facing a problem, that is add_action works out side conditional.

add_action( 'meanz_before_main_wrap', 'meanz_entry_header_structure_open', 5 ); add_action( 'meanz_before_main_wrap', function(){echo "<div class='title_cat'>";}, 6 ); add_action( 'meanz_before_main_wrap', function(){echo meanz_post_cats();}, 7 ); add_action( 'meanz_before_main_wrap', 'meanz_do_title', 25 ); add_action( 'meanz_before_main_wrap', function(){echo "</div>";}, 49 ); add_action( 'meanz_before_main_wrap', 'meanz_do_thumbnail', 50 ); add_action( 'meanz_before_main_wrap', 'meanz_entry_header_structure_close', 100 ); 

Otherwise if is use a conditional like this, it doesn’t work

if(is_single()){ add_action( 'meanz_before_main_wrap', 'meanz_entry_header_structure_open', 5 ); add_action( 'meanz_before_main_wrap', function(){echo "<div class='title_cat'>";}, 6 ); add_action( 'meanz_before_main_wrap', function(){echo meanz_post_cats();}, 7 ); add_action( 'meanz_before_main_wrap', 'meanz_do_title', 25 ); add_action( 'meanz_before_main_wrap', function(){echo "</div>";}, 49 ); add_action( 'meanz_before_main_wrap', 'meanz_do_thumbnail', 50 ); add_action( 'meanz_before_main_wrap', 'meanz_entry_header_structure_close', 100 ); } 

Don’t know why it doesn’t work. Any comments?

Sorry for wrong code. Updated the question.