How can I add target='_blank' to this code?

How can I add target=‘_blank’ to this code?

echo '<a href="' . esc_url ( $sociable_link ) . '"><i class="' . $item['icon'] . '"></i></a>';

All help greatly appreciated :slight_smile:

Like this:

echo '<a href="' . esc_url ( $sociable_link ) . '" target="_blank"><i class="' . $item['icon'] . '"></i></a>';

Use the double quotes to avoid conflicting with the single quotes that PHP is using. The alternative is to use single quotes and escape them with backslashes, but it’s a messier option and not necessary. Better to keep the HTML consistent and use double quotes for this, as you’re doing with the href value.

1 Like

Thank you :slight_smile: Thank you ralpm, such a speedy helpful reply, yes working perfectly :slight_smile:

Thank you again :slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.