How to render in template file with some conditions? I want to use render function but I don't want to show all the data which is there in the particular field. So how can restrict something from rendering in template file. Scenario is:

I have reference one field to another contentype, and I am rendering field in template file. But problem is even though the referenced node is not published, that data is displaying in the rendered field. So how can I restrict like if node is published then only I want to display that data.

One more concern is if it is possible with inbuilt functions only that will be great that saves my time of writing code and designing the data.
You should be putting the business logic of deciding what you want to show (or hide) in a preprocess function in your template.php and make use of the show and hide functions to specify what you want rendered.