Query loop - how to add target='blank' or target='self' to links according to whether they are internal or external

Hi - can anyone help with this?

I’ve got a query loop that shows both internal and external articles - I’ve done it by adding a custom field to the posts and using that as the link in the loop (so you add the url in that field, whether it’s the post itself or an external link)

So I need to add target=‘blank’ or target=‘self’ dynamically according to the type of link.

Is there a way to do this in the query?

Thanks in advance

Vik

In the end I added a yes/no ACF field to the posts then I had to create the button in a code block and pull in the field

Hey Vik,

In case you are still using Bricks or someone else finds this like me searching for a way to do this, here is my solution in another thread (both title and target) -