Skip to content

Instantly share code, notes, and snippets.

@vapvarun
Last active September 16, 2025 11:06
Show Gist options
  • Select an option

  • Save vapvarun/71625709de741c4035962ac8e5f8f2e0 to your computer and use it in GitHub Desktop.

Select an option

Save vapvarun/71625709de741c4035962ac8e5f8f2e0 to your computer and use it in GitHub Desktop.
LearnDash - Link Course Image to First Lesson | Reign Theme Fix v1.2 | JavaScript solution for direct image output

LearnDash - Link Course Image to First Lesson (Reign Theme Fix)

Makes the course featured image clickable, linking directly to the first lesson. Specifically fixed for Reign theme's .lm-course-thumbnail implementation.

Installation

Add this code to your child theme's functions.php file or use a code snippets plugin like WPCode.

What This Fixes

Reign theme outputs the course image as:

<div class="lm-course-thumbnail">
    <img src="...">
</div>

This snippet makes that entire thumbnail div clickable and links to the first lesson.

Features

  • Reign Theme Specific Fix - Targets .lm-course-thumbnail div directly
  • JavaScript Solution - Works even when PHP filters don't catch the image
  • Access Control - Only adds link if user has access to the course
  • Visual Feedback - Adds hover effect and play button overlay
  • Clean UX - Cursor changes to pointer on hover

How It Works

  1. Detects single course pages
  2. Gets the first lesson URL
  3. Checks if user has access
  4. Makes the .lm-course-thumbnail div clickable via JavaScript
  5. Adds hover effects and play button overlay

Requirements

  • WordPress 5.0+
  • LearnDash LMS
  • Reign Theme
  • jQuery (included in WordPress)

Version History

  • v1.2 - Fixed for Reign's direct image output
  • v1.1 - Added access control
  • v1.0 - Initial release

License

Free to use and modify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment