View result alter title link based on content type
You can do it via views itself with the little tweaking. 

Since you said the custom URL will not be available in other content types,


Add the required fields including custom field and the content path to your views fields. 

Open the custom URL field and go to No Results Behaviour. Add the Replacement pattern of default content path.

Created a custom text and assembled results. Make sure u refer to custom URL field to link and not the default content URL.



It should automatically work now. Whenever there is no third party URL link not available, it will fetch the default URL. This should have your issue resolved. 

But in case if the third-party URL field was available in all content type with some data, Then you need to do this in preprocess function. This approach will have issues.