Title: Shortcode for course title
Last modified: September 1, 2016

---

# Shortcode for course title

 *  Resolved [rahy](https://wordpress.org/support/users/rahy/)
 * (@rahy)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-course-title/)
 * I’m trying to use the shortcode to return the title of course [lifterlms_course_title].
   
   But putting the shortcode on the description of the course or in a widget doesn’t
   return anything. How do I use it? If using it with php do_shortcode, does it 
   need echo? I want to use it to define the name of the chatroom widget in QuickChat
   plugin.
 * Thank you
 * [https://wordpress.org/plugins/lifterlms/](https://wordpress.org/plugins/lifterlms/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Thomas Patrick Levy](https://wordpress.org/support/users/thomasplevy/)
 * (@thomasplevy)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-course-title/#post-7560434)
 * [@rahy](https://wordpress.org/support/users/rahy/),
 * As per our [docs](https://lifterlms.com/docs/shortcodes/#lifterlms_course_title)
   on the shortcode, this can, by default, only be used inside a Course or Lesson
   loop. Depending on where you add the shortcode, in a widget, for example, it 
   will only work if that widget is output inside a Course or Lesson.
 * If you use it in a custom way, via PHP, you absolutely *will* need to echo the
   results of do_shortcode(). Do shortcode, by default, only returns the content,
   it does not output it.
 * EG: `<?php echo do_shortcode( '[lifterlms_course_title]' ); ?>`
 * However, if you add this PHP outside of a course or lesson it will still not 
   output anything.
 * If you want to get the course title outside the loop, you can get the ID of your
   course (eg 123) and then use “get_the_title()” to output it.
 * EG:
 *     ```
       <?php
       $post_id = 123;
       echo get_the_title( $post_id );
       ?>
       ```
   
 * Hope that helps,
 *  Thread Starter [rahy](https://wordpress.org/support/users/rahy/)
 * (@rahy)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-course-title/#post-7560460)
 * [@thomasplevy](https://wordpress.org/support/users/thomasplevy/),
 * Thanks for your explanation. But forgive my lack of understanding this 🙂
 * What do you mean by “inside the loop”? When putting it in the description of 
   a course, it should be in the loop, right?
    When I type the shortcode only [lifterlms_course_title]
   it seems work as it doesn’t print the shortcode itself (like plain words typed
   in there), but it’s blank. So it doesn’t return anything. But when I type with
   <?php echo… it prints the whole code.
 * And the widget is displayed in the Course sidebar. So it should be in the loop
   also, right?
    I output the course metainfo in the same widget and it works.
 * Maybe I should use the post_id, I just think the shortcode will be simpler.
 * Thank you.
 *  [Thomas Patrick Levy](https://wordpress.org/support/users/thomasplevy/)
 * (@thomasplevy)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-course-title/#post-7560529)
 * [@rahy](https://wordpress.org/support/users/rahy/),
 * After closer review, we have our shortcode set to only display on lessons although
   our documentation states otherwise. My apologies.
 * This will be resolved in 2.7.9, due out later this afternoon.
 * Take care,

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shortcode for course title’ is closed to new replies.

 * ![](https://ps.w.org/lifterlms/assets/icon.svg?rev=2034507)
 * [LifterLMS - WP LMS for eLearning, Online Courses, & Quizzes](https://wordpress.org/plugins/lifterlms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/lifterlms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/lifterlms/)
 * [Active Topics](https://wordpress.org/support/plugin/lifterlms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/lifterlms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/lifterlms/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Thomas Patrick Levy](https://wordpress.org/support/users/thomasplevy/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/shortcode-for-course-title/#post-7560529)
 * Status: resolved