The aim of this study is to explore the effect of phosphate and pH on different fractionations heavy metals (HM) and bacterial community during pig manure composting. Phosphoric acid (H3PO4), sulfuric acid (H2SO4) and dipotassium hydrogen phosphate (K2HPO4) were added equimolar to the pig manure compost at the 0.25 mol/kg (dry matter). The potential ecological risks of HM of compost products were evaluated by Håkanson’s methods and the response of bacterial community was compared by network analysis. The results showed that the H3PO4, H2SO4 and K2HPO4 additives increased the HM potential ecological risk index (RI) of compost products from low to moderate level by 31.89, 20.10 and 31.40, respectively, compared to the control without additives. The network analysis showed that these additives especially H3PO4 significantly changed the composition and interaction of bacterial community. In the compost with the addition of H3PO4, the correlation between Bacteroidetes, Proteobacteria, Actinobacteria and other bacterial phyla as well as HM components were enhanced obviously. In conclusion, this study shows that the addition of PO43- reduced the relative content of acid-soluble fractionation of Mn and Zn in the compost, while the addition of H+ had the opposite effect.