A bond is very similar to a time deposit. Lets assume that we have bought a bond with nominal price €1000, annual yield 5% and expiration after 10 years. This means that for every year that we possess the bond we will have a profit of €50 (€1000 x 5% = €50). At expiration after 10 years our initial capital of €1000 will be also returned to us. The same would have happened if we had made a 10 years time deposit instead of buying a bond.
But unlike time deposits, after a bond has been issued (in primary market), it is traded in the secondary market which is something like a bonds exchange. In the secondary market those who bought bonds in the primary market can sell them to those who didn’t bought them or even buy more.
Bond prices in the secondary market are different from their nominal price and depend on their demand and supply. For example some Greek bonds were traded at 12% of their nominal price due to the Greek default. This means that if their nominal price was €1000, in the secondary market their real price was €120. Nevertheless, irrelevantly if someone bought them at nominal price or much lower, at expiration the owner will take back the nominal price (if we assume that the issuer will not default nor a haircut will take place). So, if the price in the secondary market is 50% of the nominal (€500) then the real yield at expiration will not be only 5% but much bigger because the bond buyer will also has capital gains (€1000 takes back at expiration minus €500 paid to buy them equals €500 in capital gains).
From the above example we can conclude that when the price of a bond falls its real yield (yield to maturity) rises and when price rises its real yield falls.