• function employee_plugin_activate(){
    $newpage= 'Employee Archive';
    if(get_page_by_title('Employee Archive') == false ){
    $my_page = array(
    	'post_title' => 'Employee Archive',
    	'post_content' => 'IT WORKS',
    	'post_status' => 'publish',
    	'post_type' => 'page',
    	'post_author' => 1
    );
    	$post_id = wp_insert_post($my_page);
    	//wp_insert_post($my_page);
    }//end if
    }//end function
    register_activation_hook( __FILE__, 'employee_plugin_activate' );

    /**************************************/

    //Load Employee Archive template for page Movie Reviews Archive
    add_filter( 'page_template', 'emp_load_template' );
    function emp_load_template( $page_template )
    {
        if ( is_page( 'Employee Archive' ) ) {
            $page_template = plugin_dir_path( __FILE__ ) . '/page-employees.php';
        }
        return $page_template;
    }

    This first block of code throws a ” Headers already sent error ” during plugin activation. Please help.

  • The topic ‘Custom Post Type Adds Page during activation generates " headers already sent "’ is closed to new replies.