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
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…
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
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'])) { ... }