Add Shortcode LMS pages only

Home Forums Legacy Support Support queries How-to & Troubleshooting Add Shortcode LMS pages only

Tagged: ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #117682
    pacworks
    Spectator
    Hello, I was wondering if there is a way I can add shortcode to LMS pages only (units, quizzes, etc.). I have a sticky audio player that I only want to show up on the LMS pages. I was given this code by the plugin developer to place in my header.php or footer.php file:
     if ($post->ID==100 || $post->ID==200) {
    //do nothing
    } else {
    echo do_shortcode("[lbg_audio3_html5 settings_id='1']");
    }
    
    I was thinking that I may be able to add the shortcode to a php file that only appears in the LMS sections instead of the header.php or footer.php file, but I'm not sure what the best file would be add the shortcode to.</p>
    #117759
    H.K. Latiyan
    Participant
    Hi... Please let me know what you mean by LMS pages, according to my understanding you need it on course status page where all the units and quizzes are done by a student. Please let me know if you want it only here or somewhere else also ?
    #117834
    pacworks
    Spectator
    Yes, I need it on the course status page. I have 2 options for implementing the sticky audio player. One is by inserting a line of php code into the header.php file or footer.php file. The other is to use a shortcode in the page or post I want to player to appear on. If I put the code in the header.php or footer.php file, it shows up on every page, unless I use the code I provided in my last post to specifically tell it which pages I don't want the player to show up on. This method isn't ideal because I have many pages and I will have to remember to edit this each time I create a new page. I tried putting the shortcode in the Course Status page, but it doesn't work. It looks like the shortcode is stripped out to be replaced with whichever unit or quiz is loaded.  
    #117917
    H.K. Latiyan
    Participant
    Hi.. For showing it on course status page use the hook "wplms_before_course_main_content" for example: add_action('wplms_before_course_main_content',function(){ echo do_shortcode();//Add your shortcode here just like you added in the previous code. }); You need to add this code in the wplms-customizer.php file present in your wplms customizer plugin.
    #118058
    pacworks
    Spectator
    It doesn't seem to be working. I am using a child theme. Just to confirm that I am doing it correctly, I have downloaded the wplms-customizer.zip file from the plugins folder in the WPLMS theme. I extracted the file and added the this code to the wplms-customizer.php file: add_action('wplms_before_course_main_content',function(){ echo do_shortcode('[lbg_audio3_html5 settings_id="3"]'); }); I compressed the file back into wplms-customizer.zip and uploaded the zipped folder to the plugins folder in my child theme. Is that correct?
    #118060
    pacworks
    Spectator
    I also uploaded  wplms-customizer.zip containing the code edit to wplms-customizer.php to the plugins folder in the parent theme, just to see if that worked, but that didn't seem to work either.
    #118124
    H.K. Latiyan
    Participant
    Hi... This is a plugin you do not have to upload it in the themes folder, you need to upload it in the plugins folder. But since you are using a child theme then you can also add the code in the functions.php file of your child theme.
    #118210
    pacworks
    Spectator
    That worked! Thank you for your help.
Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Add Shortcode LMS pages only’ is closed to new replies.