This research employs the generalized normal distribution optimizer (GNDO) to address the simultaneous integration of solar photovoltaic (PV) sources and distribution static compensators (D-STATCOMs) in medium-voltage distribution networks. Through a discrete-continuous codification process, the GNDO method determines the optimal locations (nodes) and capacities (sizes) of PV systems and D-STATCOMs. A power flow approach based on the successive approximations method is used to solve the power flow equations and assess the solution's technical characteristics, including voltage profiles and power injections. Using a master-slave optimization strategy, the GNDO and the power flow method are used to address the studied problem. Numerical results in the 33- and 69-bus grids demonstrate the effectiveness of the proposed approach, showing superior performance compared to the vortex search algorithm (VSA) and the sine-cosine algorithm (SCA). The results indicate reductions of approximately 35.5554% and 35.6839% when using the GNDO in both test feeders. Additionally, the GNDO reduces the computational efforts required to find solutions in both test feeders, in comparison with the VSA and the SCA. All numerical validations were performed using MATLAB 2024a.