Tag Archives: Theme Development

How to Redirect to Custom Page After Completing a LearnDash Course

One of the features I recently finished for the my redesign of my JavaScript for WordPress site was to have users taken to a special page once they complete a course.

You can do this a number of ways, but here is how I did it:

 

1. Setup Congratulations Pages for Each Course

The first thing I did was create a parent page called Congratulations with the url of “/congrats.”

Then I created Child Pages, one for each course.  Those pages looked something like this.

Screen Shot 2017-06-02 at 2.29.43 PM.png

You can see the badge displayed and the number of points earned (I use BadgeOS and BadgeOS LearnDash Add-on).

The most important thing I did was give each page the same slug as the course it is tied to.  If I didn’t do this, then the next step wouldn’t work as coded.

 

2. Add This Code to Your Functions.php

The next step was to find the LearnDash hook that fires when a LearnDash course completes.

Luckily there is a learndash_course_completion_url hook that let’s return a URL and the redirect happens automatically.

This code gets the slug for the completed course and then creates a new URL string of “/congrats/course-slug.”

NOTE: This will only work if you you did these two things from Step 1.

  • Create a parent page with the URL slug of “congrats”
  • Create child pages for each course using the same URL slug as the course

 

Hope this Helps!

If you have a LearnDash account you can access the list of Action and Filter Hooks here.  Since that page is password protected, thought I would share this snippet with you.

Hope it helps!

How to Add Meta Descriptions to WordPress Themes Using functions.php

While working on an SEO for WordPress course recently, I was looking for a way to manually add meta descriptions to a theme from the functions.php file.

After playing around a bit, I came up with this solution:

This of course raises the bigger question of why would you want to do this instead of using a plugins like SEO by Yoast or All in One SEO.  I don’t think that you actually would :p I just wanted to demonstrate how to do it.

If you have a more elegant solution, please suggest away!

Hardcode a Ninja Form in Your WordPress Theme

 

I have been a big Gravity Forms supporter for a long time, however, I’m beginning to get more interested in Ninja Forms, which is a free WordPress form builder and also quite powerful.

If you decide to build your WP forms with Ninja Forms, you may find the ninja_forms_display_form() function helpful since it let’s you hardcode a form directly into a template.

Most of the time I add my forms as shortcodes, but on occassion it’s necessary to hardcode in the form to the theme files itself. Here’s the full documentation for the ninja_forms_display_form hook.

Learn WP from Static HTML to Custom Theme

Rock on to the folks at WP Tuts for staying up to date on publishing WordPress theme tutorials!

Here is the latest in their series:

  1. Creating a WordPress Theme From Static HTML: Preparing the Markup
  2. Creating a WordPress Theme From Static HTML: Creating Template Files
  3. Creating a WordPress Theme From Static HTML: Uploading Your Theme to WordPress

Thanks Rachel for your great work!