• Resolved John

    (@artoftech)


    Hello,
    I have a need to add instructions to the end of the filter section in the sidebar of the course archive.
    I found that I could append to the content in this file: /learnpress/inc/TemplateHooks/Course/FilterCourseTemplate.php (around line 574), but I need the child theming alternative so it doesn’t get overridden in an update. Can you tell me where to code this since there are no hooks in this file? I thought about a CSS ::after pseudo-element but that is a bit hacky and doesn’t give me a div or class.

    $content .= '<div class="attribution-notice">*Authored in part by the attributed...</div>';	

    return $content;

    This adds a footnote below the Author section. My assumption is that only files in the templates folder (child-theme/learnpress) can be overridden as explained this way: https://thimpress.com/knowledge-base/overriding-learnpress-templates/, and this file is under the inc folder and doesn’t have any hooks…

    Thanks in advance!
    John

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support brianvu-tp

    (@briantp)

    Hi John,

    Thank you for reaching out!

    We understand you’d like to add content to the end of the filter section in the sidebar of the course archive.

    You can try using the lp/filter-courses/sections/wrapper hook. This hook, located in the same FilterCourseTemplate.php file. Try adding the following code to your child theme’s functions.php file:

    add_filter( 'lp/filter-courses/sections/wrapper', function( $wrapper ) {
        $wrapper['attribution'] = '<div class="attribution-notice">*Authored in part by the attributed...</div>';
    
        return $wrapper;
    }, 10, 2 );

    Please let us know if this works as expected or if you have any further questions.

    Best regards,
    Brianvu-tp

    Thread Starter John

    (@artoftech)

    Hi Brianvu-tp,
    Thanks for the quick response! This does work, however it adds a piece of text: “attribution” at the top of the filter in this case. This comes from the wrapper array defined on the first line b/c I can change it and it displays whatever is in the bracket notation. Here is the code structure from an inspect:

    <form class="lp-form-course-filter">
    "attribution"
    <div class="lp-form-course-filter__item">
    <div class="lp-form-course-filter__title">Search</div>
    ...lots omitted...
    <button type="submit" class="course-filter-submit">Filter</button>
    <button class="course-filter-reset">Reset</button>
    <div class="attribution-notice">
    "*Authored in part by the attributed..."
    </div>
    </form>

    Appreciate any additional clarification.
    John

    Plugin Support brianvu-tp

    (@briantp)

    Hi John,

    Thank you for your response!

    We have tested the code snippet we provided:

    add_filter( 'lp/filter-courses/sections/wrapper', function( $wrapper ) {
        $wrapper['attribution'] = '<div class="attribution-notice">*Authored in part by the attributed...</div>';
        return $wrapper;
    }, 10, 2 );

    After inspecting the output on our end, we did not see the text “attribution” being displayed as you described. We conducted our test using the Twenty Twenty-Five theme and the latest LearnPress release (4.2.7.7).

    Could you please double-check your custom code to see if any modifications or additional filters might be affecting the output? Let us know what you find, and we’d be happy to assist further!

    Best regards,
    Brianvu-tp

    Thread Starter John

    (@artoftech)

    Much appreciated. I will set up a test instance and check…

    Plugin Support brianvu-tp

    (@briantp)

    Hi John,

    Thank you for your response!

    We look forward to hearing about your findings on the test instance. Let us know what you discover!

    Best regards,
    Brianvu-tp

    Thread Starter John

    (@artoftech)

    All good after updating to 4.2.7.7

    Thanks as always!

    Thread Starter John

    (@artoftech)

    Please note:
    Before this update the hook name for apply_filters was: learn-press/filter-courses/sections/wrapper

    this is now: lp/filter-courses/sections/wrapper

    Plugin Support brianvu-tp

    (@briantp)

    Hi John,

    We’re glad the update resolved the issue.

    Thanks for letting us know, and thank you for pointing out the change in the hook name – that’s valuable information for other users as well.

    Best regards,
    Brianvu-tp

    Thread Starter John

    (@artoftech)

    Minor thing after updating to 4.2.7.8

    The filter loads this correctly the first time, and then clicking on any filter item, adds it a second time as another div. Subsequent clicks don’t add it again however. Checking for existence doesn’t seem to help, but I’m not sure I’m doing the check correctly:

    if (!isset($wrapper['attribution'])) { ... }
Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.