When a WordPress site gets cleaned and then gets infected again, the problem is almost never WordPress itself. The real cause is almost always a theme or plugin that has bugs or hidden bad code. If you reinstall WordPress but put the same unsafe theme or plugin back on the site, the malware usually returns quickly, sometimes in just a few hours. Server security helps, but it cannot protect you if a file inside your site is letting attackers in.
A clean fix starts with a true reset. Make a full backup so you don’t lose your images. Change every password that touches the site, including your hosting login, SFTP or SSH, the database, and every WordPress admin. Remove any admin users you don’t recognize. Delete all files in the site’s folder so no old backdoors remain. If you keep the uploads folder for your images, make sure it has no files ending in “.php,” because images do not need to run code.
Install a fresh copy of WordPress from wordpress.org or from your hosting control panel. Turn the site on using a default theme like Twenty Twenty-Four. Do not add any extra plugins yet. Let the site run like this for a bit. If nothing bad comes back, you know the core is clean.
When you start adding features again, only use themes and plugins that are well known and kept up to date in the official WordPress.org directory. Add them slowly, one at a time, and check that the site stays stable after each one. Avoid “free premium” or “nulled” downloads from random websites. Those are a common way malware gets in.
A few small changes make a big difference going forward. Keep WordPress, your theme, and your plugins updated so security fixes are applied. Use fewer plugins so there is less to attack.
If you follow these steps, reinfections usually stop. The simple idea is to keep WordPress core clean, use only safe and maintained add-ons, and close the easy doors that malware uses.