WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type Adds Page during activation generates " headers already sent " (1 post)

  1. Cerzky
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic