function to get target post