• Resolved rahy

    (@rahy)


    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://www.ads-software.com/plugins/lifterlms/

Viewing 3 replies - 1 through 3 (of 3 total)
  • @rahy,

    As per our docs 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

    (@rahy)

    @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.

    @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.