Feed composition affects the gut bacterial community in aquatic species, but little is known about how diet type impacts gut microbiota in molluscan bivalves. This study investigates the impact of feed composition on the gut bacterial community in two commercially important bivalves: Pacific oyster Magallana gigas and Mediterranean mussel Mytilus galloprovincialis. Oysters and mussels were fed with two types of marine algae, live Isochrysis galbana (microalgae) and the dried seaweed powder Ulva sp. (macroalgae) under a laboratory condition for two months. The V1–V2 region of the 16S rDNA was sequenced through an Illumina MiSeq platform to compare the gut bacterial community of oysters and mussels at the start and the end of the feeding trial. Feed composition directly impacted both alpha and beta diversities of gut microbiota, but the degree of the impact differed between bivalve species. The difference in the gut bacterial assemblages of oysters and mussels in the pre- and post-feeding trials indicated that the diet type and host species shape the composition of gut bacteria. Spirochaeta was absent in mussel guts during the pre- and post-feeding trials but was present in oysters, revealing host specificity in colonizing gut bacteria. The results suggest that the diet type and host species can significantly impact the gut bacterial community structure. This study confirms that diet can modulate gut microbial composition in marine filter-feeding organisms, but the extent of dietary modulation depends on feed type and host species.