Fetal pigs, like all mammals, filter waste through the placenta. Fetuses develop with an amniotic sac, placenta and an umbilical cord. These three components serve the same function across mammalian development. The amniotic sac houses the embryo and the placenta, which are attached via the umbilical cord.
The mother's blood passes through the placenta and cord carrying nutrients, and then the waste product is carried back out through the cord to be filtered by the placenta. The filtered blood is then returned to the mother. The fetus doesn't produce urine or fecal matter, even after the development of the digestive and urinary tract, because it doesn't yet digest food. Instead, all nutrients are received and expelled via the bloodstream.
The placenta serves as a filter between the mother and fetal pig's blood streams so that the two are never in direct contact. However, the placenta cannot filter out all undesirables, such as some drugs, or in the case of people, alcohol. After the baby is born, the umbilical cord attached to the placenta is cut, and the piglet begins typical digestive processes to ingest nutrients and expel waste. The placenta is also birthed by the mother following the piglet, as it is no longer needed.