William Dunlap was born around 1830 in South Beaver, Pennsylvania, possibly to James and Mary Dunlap. He grew up and attended school in Beaver County, Pennsylvania, before enrolling in the Curry Institute in Pittsburgh. He worked as a teacher in the 1850s. He married Matilda Kennedy around 1855, and their daughter Anna was born around 1858.
He enlisted in the Union army on September 1, 1862, and he mustered in as a corporal in Company F of the 139th Pennsylvania Infantry later that day. He took part in the Battle of Antietam, the Battle of Fredericksburg, the Battle of Gettysburg, the Overland Campaign, and the siege of Petersburg. He was promoted to sergeant on August 15, 1863. He joined the Presbyterian church during the war and eventually became an elder. He was wounded several times, most notably in the Battle of Cedar Creek on October 19, 1864. He mustered out in Washington, D.C., on June 21, 1865.
Dunlap settled in McCandless, Pennsylvania, after the war and earned a living as a farmer. By 1870, he owned $1,040 of personal property. He applied for a federal pension in August 1871 and eventually secured one. He returned to South Beaver around 1881 and purchased 80 acres of land. His property eventually grew to 180 acres. He died on March 8, 1900.