This page on wikipedia gives a good synopsis of these concepts.
The confusion lies in the fact that many websites on anatomy discuss/describe/define these terms in relation to humans. However, in quadrupeds and fish (and birds), Anterior/Posterior lies orthogonal to Ventral/Dorsal and are instead synonymous with Cranial(Rostral)/Caudal. Examining the etymologies of the 4 terms in question will demonstrate why there seems to be an inconsistency in their usage:
Ventral -> "belly" side
Dorsal -> "back" side
Anterior -> "before" or "toward the front"
Posterior -> "after" or coming after (opposite to) the anterior
Based on the body orientation of the organism (often associated with forms of locomotion), these terms can sometimes overlap (as in bipedal humans) but often lie perpendicular to each other (as in quadrupeds, fish and most birds).
Think of ventral (Latin venter = "belly") as being associated with the belly side (with belly referring to "swelling" or "inflating") -- or typically the side of the organism containing the digestive and respiratory organs. Dorsal (from Latin dorsum meaning "back") refers to the body region/"side" opposite that of ventral (and typically called the "back").
Anterior (from Latin ante meaning "before" or "in front of") refers to the "front" of the organism (i.e., the part of the organism you'd encounter 1st or before other body regions). Posterior (from Latin, comparative of posterus ("following") from post- meaning "after") is the opposite and refers to the part of the organism encountered "after" (or opposite) the anterior side.
Depending on the orientation of the organism, these terms may be synonymous in some instances but be orthogonal in other instances).
Sometimes anterior/posterior would be synonymous with ventral/dorsal, as is the case in humans or other bipedal organisms.
In other instances (e.g., in quadrupeds, fish or birds), posterior/anterior lies relatively orthogonal to the dorsal/ventral orientation. In these cases, dorsal/ventral is instead synonymous with superior (from Latin superior, comparative of superus "that is above," from super "above") and inferior (from Latin inferus meaning "low" or "below").
- Often in these cases, anterior/posterior are instead associated with caudal/cranial (common alternatives for cranial include cephalic or rostral). Caudal (from Latin cauda meaning "tail") refers to the tail side of the organism (i.e., the side associated with coccygeal vertebrae or sometimes simply the side of the organism where waste is excreted). Conversely, cranial (Greek kranion = "skull") or cephalic (from Latin cephalicus, from Greek kephalikos, from kephalē meaning "head") refer to the side of the organism containing the head. Rostral (referring to rostrum from Latin meaning "beak") is another synonym for cranial and refers to being "situated or occurring near the front end of the body, especially in the region of the nose and mouth or (in an embryo) near the hypophyseal region."
This English.SE question addresses etymology of the suffix "-erior."
You can find a pretty good list of anatomical etymologies here, here, here, or by simply searching "[word of interest] etymology" in Google.
Also, this Bio.SE post addresses anatomical terminology usage in plants and body organs.
More generally, a frontal plane always divides an organism into ventral/dorsal.
Although these terms differ between shapes/orientations of organisms, using such terms for more specific body parts (e.g., heads or feet) are not always as inconsistent.
- For example, anatomical positional terminology for brains is consistent across organisms.
One final note:
This approach to anatomical positional terminology only works with bilaterally symmetrical organisms. See here for terminology usage for other organisms.