There are several issues here.
/j/ and /w/ are phonologically consonant sounds in English
Yes, the semivowels /j/ and /w/ are classified as consonant sounds in English, even though phonetically they are like vowels. That’s just how English works. This applies most noticeably to the a/an rule: we say “a year,” “a university,” “a woman,” “a one-time deal” and as far as I know, no modern English speaker would find *"an university" or *"an one-time deal" acceptable.
Pronunciations of “the”
The form /ði/ is used, no matter what the following sound is, when this word is emphasized. The most common context where the is emphasized might be a contrast with another determiner like “a/an”.
In non-emphatic contexts, the situation is more complicated. However, the rule you were taught is correct. There are just other factors that can affect pronunciation. I’m taking the following information from “Constraints on definite article alternation in speech production: To “thee” or not to “thee”?” by M. Gareth Gaskell, Helen Cox, Katherine Foley, Helen Grieve, and Rachel O’Brien, which is specifically about British English speakers.
In non-emphatic contexts where the following sound is a consonant, the form /ðə/ is usually used. However, there are a few factors that increase the likelihood of using /ði/ before a consonant sound.
- second-syllable stress
- the glide /j/, even more so where it is spelled with the letter <u>
In non-emphatic contexts where the following sound is a vowel, the form /ði/ is usually used. However, there are a few factors that increase the likelihood of using /ðə/ before a vowel sound.
- first-syllable stress
- the vowel /i/ or /ɪ/ (the greater likelihood of using /ə/ before these than before other vowel sounds can be seen as a form of dissimilation: it's awkward to have two identical or similar sounds right next to each other)
Despite the existence of factors that increase the likelihood of using the “opposite” form, Gaskell et al. found that the vast majority of the 50 adults in their study closely followed the consonant-vowel rule. So for an English language learner, I would recommend learning to apply this rule, although it’s not a big deal if you use the “opposite” form: native speakers do also sometimes. Obvously native speakers don't have to try to follow this rule (most of them will automatically, but some might not), but this site is not for native speakers.