John
Forum Replies Created
-
Thank you for the follow-up Brianvu-tp.
After having purchased the Collections add-on, I have discovered a better way to do this via the List Courses Widget. It actually simulates the all courses archive perfectly if using Elementor, can be customized much easier than the Collections.
If someone else is considering this, my advise is to take a look at the widget first…
Best,
JohnHi Brianvu-tp,
This was one thought, but after experimenting we have decided on using a combination of the collections and course archive with filtering.Best,
JohnHello Brianvu-tp,
Thanks for the response. Given that we cant have 2 course archives for the same site, that was my first thought, but I am experimenting with separating the 2 collections and just having one use filters. The other set is smaller and we may be able to get away without. In any case; If that doesn’t work out, we might consider 2 distinct sites under separate subdomains.
As always, your support is appreciated!
John
Thank you Brianvu-tp,
Then I’m guessing maybe a subdomain each with it’s own LP installation is the only way at this point:
https://mydomain/collection1 (with all-courses archive/filters)
https://mydomain/collection2 (with separate all-courses archive and filters)Let me know if this isn’t reasonable.
Best,
JohnOk, thanks to you both I got this working now. Had to do a Google Translate but got the gist giann3464.
Gracias!
Now that I unassigned my self from a course I see that if I am logged in, it defaults to this behavior already. Slick!
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'])) { ... }Please note:
Before this update the hook name for apply_filters was: learn-press/filter-courses/sections/wrapperthis is now: lp/filter-courses/sections/wrapper
All good after updating to 4.2.7.7
Thanks as always!
Much appreciated. I will set up a test instance and check…
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.
JohnHi, I corrected a few things and got this to work:
add_filter('learn-press/layout/list-courses/item/section/bottom', function($section_bottom, $course, $settings) {
$html_tags = $course->tags[0]->name; //since we only have one tag don't need to loop the array
if ( ! empty( $html_tags ) ) {
$html_tags = sprintf(
'<div>%s</div>',
$html_tags
);
}
$custom_field = get_post_meta( $course->get_id(), 'lp_alt_title', true);
if($custom_field != '') {
$alt_title = sprintf(
'<div class="all-courses-alt-title">%s%s%s</div>',
"(",
$custom_field,
")"
);
}
array_splice($section_bottom, 2, 0, $alt_title);
array_splice($section_bottom, 6, 0, $html_tags);
return $section_bottom;
}, 10, 3);Thanks Brianvu-tp,
Works a charm!
Best,
JohnHello,
Again for anyone following along I’m posting the final solution that support from ThimPress helped me craft:
/* Add new Tag sorting option */
function oht_create_new_tag_sort_option( $order_by ) {
$order_by = array(
//New sort option
'course_tag' => esc_html__( 'Page Number', 'learnpress' ),
//Remaining used sort options
'post_date' => esc_html__( 'Newly published', 'learnpress' ),
'post_title' => esc_html__( 'Title a-z', 'learnpress' ),
'post_title_desc' => esc_html__( 'Title z-a', 'learnpress' ),
'popular' => esc_html__( 'Popular', 'learnpress' )
);
return $order_by;
}
/* Handle the query to sort by course tag */
add_filter('lp/courses/filter/order_by/course_tag', 'query_order_by_tag');
function query_order_by_tag(LP_Course_Filter $filter): LP_Course_Filter {
$lp_course_db = LP_Course_DB::getInstance();
$filter->join[] = "INNER JOIN $lp_course_db->tb_term_relationships rel ON p.ID = rel.object_id";
$filter->join[] = "INNER JOIN $lp_course_db->tb_terms terms ON rel.term_taxonomy_id = terms.term_id";
$filter->where[] = "AND terms.slug LIKE 'page-%'";
$filter->group_by = "p.ID";
$filter->order_by = "SUBSTR(terms.slug,6,2)+0";
$filter->order = "ASC";
return $filter;
}Thanks again for your stellar support!
Best,
JohnDo you mean this site? https://help.thimpress.com/