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

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

I would like the social urls opening in a new page.

<!-- Header top bar Socials -->
                            <?php if(!empty($socials)): ?>
                                <div class="pull-right">
                                    <div class="copyright-socials">
                                        <ul class="clearfix">
                                            <?php foreach ( $socials as $key => $val ): ?>
                                                <li>
                                                    <a href="<?php echo esc_url ($val )  ?>">
                                                        <i class="fa fa-<?php echo esc_attr($key); ?>"></i>
                                                    </a>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                    </div>
                                </div>
                            <?php endif; ?>

All help greatly appreciated. thank you.

Edit the file?

<a href="<?php echo esc_url ($val )  ?>" target="_blank">
    <i class="fa fa-<?php echo esc_attr($key); ?>"></i>
</a>
1 Like

Hello Mittineague, many many thank yous for your fast reply, your code is working perfectly :smile:

I had placed the target=“_blank” in many different places, yet not there.

Thank you again, much appreciated :slight_smile:

1 Like

Are you aware that without target=“_blank” that your visitors have three options on where the link opens and that all that target=“_blank” does is to remove one of those options for some of your visitors while having no effect whatsoever on the rest.

Where links open is controlled by

  1. your visitor
  2. their browser settings

and only if they allow it can you remove an option by adding a tag flagged for removal from HTML back in 1997.

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