Course Grid: Open Courses in New Tab

Updated 2 years ago
by Dave Warfel

NOTE
This code only works for LearnDash Course Grid 1.x and/or when using the

shortcode. It does not work with version 2.x of the Course Grid plugin, the Course Grid block, or the [learndash_course_grid] shortcode.

In your grid, if you’d like to open each course in a new tab, you can use the following code. This code was generously submitted to us by Patrick Kellogg. Patrick helps out in the LearnDash Facebook group, knows LearnDash inside and out, and is an all-around great guy. Thanks Patrick!

A few quick caveats:

  • This code requires jQuery. LearnDash uses jQuery so unless you are knowingly disabling it (which you probably shouldn’t be), you should be fine.
  • Be sure to update the ID of the page where your grid is located. How to find the page ID →
function pfk_learndash_course_grid_open_in_tab() {
	// *Important* change 0 to equal the post_id of your course grid page.
	if (is_page( 0 ) ) {
		?>
			<script>
				jQuery(".ld_course_grid a").attr("target", "_blank");
			</script>

		<?php
	}
}

add_action( 'wp_footer', 'pfk_learndash_course_grid_open_in_tab');

All CSS code should either be placed in a child theme’s main CSS file (typically style.css), or the Additional CSS area of the WordPress Customizer.

How to Add CSS to Your Site

Forum Rules

Be Kind & Patient

We’re here to learn and/or help each other. Please don’t be mean, rude, or condescending. Treat all members the way you should be treating dogs and your elders—with the utmost love & respect.

External Links

✅ Other websites that add value, help solve problems & contribute to the discussion. ❌ Affiliate links are prohibited. (Site owners may use affiliate links to help support the site.)

Promotion

✅ You may promote your own products/services if they are relevant to an existing discussion. You must disclose your relationship with the product(s).
❌ You may not create new posts simply to promote your products.

Non-LearnDash Topics

❌ General (free) Forum: Only LearnDash-specific topics are allowed.
✅ Premium Forums: You are allowed to post other questions tangentially related to LearnDash. Please use the appropriately named forum. If it doesn’t exist, use the “LearnDash Integrations” forum.

Our Right to Remove

We reserve the right to remove any content, at any time, for any reason. We can also merge one post with another. We will exercise caution when removing content and always try to provide an explanation.