Subscribe On YouTube

Join other subscribers and enjoy other Divi video tutorials!

How To Open Divi Blog Post Links In A New Tab By Default

Nelson Miller Profile Orange
In this tutorial, I will show you how to automatically open Divi Blog post links in a new tab by default using a jQuery snippet.

▶️ Please watch the video above to get all the exciting details! 👆

1. Add A Custom CSS Class To The Divi Blog Module

The first step is to add a custom CSS class to the Divi Blog module. Using a custom class like this will make sure that our code only affects the module with this class, rather than affecting other Blog modules on your site.

Open the Divi Blog module settings and go to the Advanced tab and open the CSS ID & Classes toggle. From there, copy and paste or write “pa-blog-new-tab” into the CSS Class input field, as shown in the screenshot.

add custom css class to Divi blog module to open links in new tab

2. Add The jQuery Code Snippet

Now that the CSS class is added to the Blog module, we will add a snippet of code that references the class and makes the posts within that Blog module open in a new tab. The code is finding the image, title, and read more button and adding the blank target to the links, which simply means the links will open in a new tab instead of the same tab.

Where To Paste The jQuery Code

If you are using Divi Assistant, simply paste the code in the jQuery tab in the custom code window (be sure to enable it in the Code Helper settings first).

If you are using a child theme such as our free Divi child theme, place this snippet into the scripts.js file (remove the <script> tags at the beginning and end).

Otherwise, place this code in your Divi>Theme Options>Integrations tab in the “Add code to the < head > of your blog” code area.

If you need help understanding where to paste the code, please check out our complete guide about where to add custom code In Divi.

<script>
jQuery(document).ready(function(){
    jQuery(".pa-blog-new-tab article a").each(function(){
        jQuery(this).attr("target", "_BLANK");     
    })
})
</script>

Once you add the jQuery code, the tutorial is completed and the blog posts will now open in a new tab! If you enjoy our weekly Divi tutorials, then please subscribe on YouTube and on the blog.

Categories: Tutorials

Subscribe For More Things Like This!

At the start of each month, we send out a recap newsletter from the month before with family news, Divi news, our latest tutorials, and product news. Occasionally, if the news is too exciting to wait, we will send out another email separate from the monthly newsletter. That’s what you get when you subscribe, and of course you can unsubscribe if you are no longer interested!

Blog Post Optin
Divi Logo (2)

Shop Our Divi Products

Plugins • Courses • Templates

Visit The Shop

Featured Products

Asset 4

New! Trail Guides

Follow a series of blog posts carefully arranged around a specific topic or goal! Keep track of your progress by marking posts completed, just like a free course!

View Trial Guides

Divi Tutorials On YouTube

Our videos have views! Join subscribers and enjoy over video tutorials!

Visit Our Channel

Leave A Response!

By commenting you agree to our Blog & YouTube Comments Policy

18 Comments

Comments By Others

  1. Ole Vedel Rasmussen

    Hi Nelson
    I have a problem on a site using Divi Flash Filterable CPT.
    The blog posts in ‘Quadsat in the news’ should point out of the page – (blank)
    I tried your code for the blog – and also tried to modify it, but cant get it to work.
    Do you know a solution for this?

    Reply
  2. Ole Vedel Rasmussen

    Hi Nelson.

    Thanks for your great tips.
    I tried to use your code on a page where I use a Divi Flash Filterable CPT module.
    But it doesn’t work. It the bottom links ‘Quadsat in the news’

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      I can see that you’re not using the default Blog module. Can you please share the page URL so that I can provide the updated code as per the module?

      Reply
  3. Silke Ernst

    Hi Nelson,

    So great, all your work!!!

    I am helping a friend for his site.

    Is this code also possible to open filterable projects in a new window?

    Thanks for your help, or advice.

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Siike!

      Please use the following code for the Filterable portfolio module. Use the class pa-portfolio-new-tab in the module instead of above one:

      jQuery(document).ready(function(){
      jQuery(“.pa-portfolio-new-tab .et_pb_portfolio_item a”).each(function(){
      jQuery(this).attr(“target”, “_BLANK”);
      })
      })

      Hope it helps!

      Reply
  4. Lloyd Collins

    This is great, thanks. Is there any way to open results from the search module in a new window too?

    Reply
  5. Tom

    Thanks, Nelson.

    Divi support was not able to help me resolve this. Your tutorials have helped me in the past, and I’m very glad to have found this one. I added your code to:

    Divi Theme Options > Integrations > Add code to the of your blog

    Worked like a charm. I just subscribed to your website newsletter. Thanks for making it available.

    Reply
  6. Kat

    This just made me do a happy dance!!! Thank you for your clear and easy to follow instructions. You saved my a$$!

    Reply
  7. Sawdien

    How useful, thank you so much!
    I have a question though, I’m displaying only a few posts on my blog module and using pagination to navigate through the older posts. The feature perfectly works on page 1 but as soon as I click on a post on page 2 and so on, it opens within the current tab.

    Any idea why? Is there a way to amend the snippet to make in work on the whole module no matter the page?

    Thanks a lot!

    Reply
  8. Francesco Cap

    Hi! that’s very udeaful for blog articles! I need a similar things.. I need to open the portfolio (projects) item (from the Divi portfolio module) in a popup or overlay or blank page. How I can do that? Thank you!

    Reply
    • Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

      By default, the Divi Projects are like single posts, so clicking on one will go to the single post. I am not aware of any other way to do it. You could use a Gallery modules instead to open the images in a lightbox.

      Reply
  9. Bill Horvath

    Thanks Nelson, that was a life saver!

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Recent Posts

Shopping cart0
There are no products in the cart!
You may be interested in…
$19.00$22.50

Select options This product has multiple variants. The options may be chosen on the product page

$16.50$24.00

Select options This product has multiple variants. The options may be chosen on the product page

$16.50$24.00

Select options This product has multiple variants. The options may be chosen on the product page

$19.00$24.00

Select options This product has multiple variants. The options may be chosen on the product page

$20.50$24.00

Select options This product has multiple variants. The options may be chosen on the product page

Graphic showcasing Divi Assistant features and toolset.
From: $69.00 / year

Select options This product has multiple variants. The options may be chosen on the product page

Divi Search Helper Plugin By Pee Aye Creative
From: $29.00 / year

Select options This product has multiple variants. The options may be chosen on the product page

Continue shopping
0