An opiate is a substance derived from the poppy plant (which contains opium). Opiates are sometimes called "natural" since the active ingredient molecules are made by nature, not manufactured by chemical synthesis. Common opiates include morphine and codeine, both made directly from poppy plants.
An opioid is a substance (molecule) that is synthetic or partly synthetic, meaning the active ingredients (molecules) are manufactured via chemical synthesis. Opioids may act just like opiates in the human body, because of the similar molecules.
opiate - narcotic analgesic derived from a opium poppy (natural)
opioid - narcotic analgesic that is at least part synthetic, not found in nature
The terms are often used interchangeably. On the street, "heroin" may mean synthetic, natural, or semi-synthetic compounds. Manufactured opioids like Oxycontin are sometimes called "synthetic heroin", also adding to the confusion. Genuine "heroin" as originally formulated is technically considered an opioid, since it is chemically manufactured, although molecules from the opium plant are used in the process. Some of heroin's active ingredient molecules are not found in nature.
Currently many references are using opioid to refer to all opium-like substances (including opiates and opioids), and limiting the use of "opiates" to only natural opium poppy derived drugs like morphine.
The latest trend is illegal synthetic chemical compounds made in China and illegally smuggled into Canada, Mexico, or the US to be sold as an additiive to street heroin. By modifying fentanyl or acetyl fentanyl or sudefentanyl, they create drugs like carfentanyl, thousands of times more powerful (as a sedative) than morphine or heroin. It kills the user, by simply sedating them into such a deep state they stop breathing and suffocate while unconscious.