Changes in the gut microbial composition of the sow during lactation may influence the gut microbial colonization in their offspring, for which less information was available in the literature. This study aimed to assess: 1) the changes that occur in the bacterial and fungal communities in sow feces during the 28-day lactation period as well as in gastric and cecal digesta of piglets until one week after weaning, and 2) bacterial and fungal taxa in cecal digesta of the piglets postweaning that associate with fecal consistency. Aside from sow milk, piglets had access to creep feed from day of life (DoL) 3. Fecal samples from sows for microbial analysis were collected (n=20) on days postpartum (DPP) 1, 6, 13, 20 and 27, as well as from weaned piglets for fecal scoring on DoL 30 and 34. Gastric and cecal digesta of piglets was collected on DoL3, 7, 14, 21, 28, 31 and 35 (n=5/sex/DoL). Progressing lactation affected bacterial and fungal communities in sow feces, including 10.3- and 3.0-fold increases in the relative abundances of Lactobacillus from DPP1 to 6 and Kazachstania from DPP1 to 13, respectively (P < 0.001). Although time- and gut site-related differences existed, bacterial and fungal taxa found in sow feces were also present in gastric and cecal digesta of piglets, which supports their role for gut colonization in neonatal piglets. In piglets, bacterial and fungal alpha-diversities showed certain fluctuations during the suckling period, whereby weaning affected more the fungal than bacterial diversity at both gut sites (P < 0.05). At both gut sites, Lactobacillus largely increased from DoL3 to 7 and remained a dominating taxon until DoL35 (P < 0.05). Postweaning, plant-glycan fermenters (e.g., Prevotella-9) seemed to replace milk-glycan fermenting Fusobacterium and Bacteroides (P < 0.05). In gastric and cecal digesta, Kazachstania, Tausonia, Candida and Blumeria were dominating fungi from DoL3 to 35, with Kazachstania becoming even more dominant postweaning (P < 0.001). Fecal consistency was softer on DoL34 than 30 (P < 0.05). Correlation analysis identified that softer feces were linked to the relative abundances of plant-glycan and proteolytic bacterial taxa including pathobionts (e.g., Clostridium sensu stricto) in the cecum on DoL34. However, the potential association between cecal mold and plant-pathogenic fungi Talaromyces, Mrakia, and Blumeria and softer feces are worth to investigate in the future in relation to (gut) health of piglets.