Visual ComposerWordPress Plugins

How to open “Portfolio” Visual Composer Elements in a new tab

By May 7, 2021No Comments

Using a little bit of Javascript, you can easily open your portfolio element into a new tab.

Out of the box (straight up copy and paste):

Works with:

Salient WordPress Theme (straight up copy-n-paste)

Any WordPress theme running Visual Composer (either remove or swap out “nectar-” from the code below, which is specific to Salient theme)

Here’s the code:

<!-- mittun code -->
<!-- opens portfolio item in a new tab -->

<script type="text/javascript">
jQuery( document ).ready(function() {   jQuery('.nectar-post-grid-item a').attr('target', '_blank');
});
</script>

<script type="text/javascript">
jQuery( document ).ready(function() {   jQuery('.nectar-post-grid .nectar-post-grid-link').attr('target', '_blank');
});
</script>

How to implement for Salient:

  • Copy the code above
  • Add a raw/custom HTML VC element to the top of your portfolio page
  • Paste this snippet into the custom code section
  • Make sure the element has all padding/margin set to 0.
  • Save/publish
  • You’re done! (well, test it first,

How to implement on all other sites using VC:

  • Copy the code above
  • Add a raw/custom HTML VC element to the top of your portfolio page
  • Paste this snippet into the custom code section
    • Remove “nectar-” from the code snippet, or
    • Replace “nectar” with a different class being used by your theme/site
  • Make sure the element has all padding/margin set to 0.
  • Save/publish
  • You’re done! (well, test it first,

Example in the wild:

Causegive — causegive.org

Need help?

Please reach out to us here.

Leave a Reply