Remember that's the INTEREST on the loan, not the loan itself, that's deductible. And the interest is only deductible if the loan is secured by the property (or some other real estate property such as a home equity loan). Taxes are deductible regardless of a loan or not.
These deductions only apply if you itemize your taxes. If you file a standard deduction then you don't get them.
The above comments are general only. Your circumstances may be different.
Verify with your tax advisor if you have any specific questions.