Indeed, you should implement your logic in the body of the trigger. What you can do is to use SELECT ... INTO to store the result of queries in local variables (that you first declare in the header of the trigger). Then use IF-THEN-ELSE to get the program flow you need. In the conditions of the IFs, you can refer to local variables but not execute queries.
If you get lots of errors, try removing most of the body of your trigger and see if it compiles, then introduce a line or two at a time and make sure it compiles with each addition.