John
Forum Replies Created
-
Hi and many thanks for the follow-up! Sorry, I’m a bit confused, the link you sent above (https://ww.wp.xz.cn/plugins/learnpress/) after clicking on Support resolves to:
https://ww.wp.xz.cn/support/plugin/learnpress/,
which is the same forum:
https://snipboard.io/HYk0CQ.jpg
I have included the listing of my post in the screenshot above with URL.I’d be happy to post this in the correct forum if you could send me the appropriate link.
Thanks again,John
Hi again,
Not giving up on this. Here is what I’ve got for the above mentioned hook:
function oht_create_tag_sort_handler( $filter ) {
switch ( $filter->order_by ) {
case 'price':
case 'price_low':
if ( 'price_low' === $filter->order_by ) {
$filter->order = 'ASC';
} else {
$filter->order = 'DESC';
}
$filter = $lp_course_db->get_courses_order_by_price( $filter );
break;
case 'popular':
$filter = $lp_course_db->get_courses_order_by_popular( $filter );
break;
case 'post_title':
$filter->order = 'ASC';
break;
case 'post_title_desc':
$filter->order_by = 'post_title';
$filter->order = 'DESC';
break;
case 'menu_order':
$filter->order_by = 'menu_order';
$filter->order = 'ASC';
break;
case 'tag_id':
$filter->order_by = 'tag_id';
$filter->order = 'ASC';
break;
default:
$filter = apply_filters( 'lp/courses/filter/order_by/' . $filter->order_by, $filter );
break;
}
return $filter;
}
add_filter( 'lp/courses/filter', 'oht_create_tag_sort_handler', 10, 1 );This returns the tag_id, ASC strings when selected but it doesn’t affect the query and produces ‘No courses found’.
There has to be more to setting up the query but I can’t find it in this file.
Thanks again for the great support!Sorry, wasn’t aware bumping was a no-no, but it appears this is stalled and I think we’re very close. Any updates?
Thanks again!
Forum: Plugins
In reply to: [The Events Calendar] Month View more than one event in a week breaks layoutI appreciate the response, but you may note in my post I did 90% of this already. As I was testing further, it turns out the specific HTML I was using in the excerpt caused this to break in both the staging and local instances.
So, not a fault of the plugin or a conflict. Just an unclosed tag breaking the rest of the layout.
Thanks for your support and I hope this helps someone down the road if they miss checking their HTML for proper syntax.Forum: Plugins
In reply to: [The Events Calendar] Add tags and organizers to events listing pageAh, then that is the answer – populate the excerpt manually. Problem solved. Thanks!
To follow up I pieced the actual query I need together. It goes like this:
SELECT posts.id, posts.post_title, terms.name fromwpp9_postsas posts
INNER JOINwpp9_term_relationshipsas rel
ON posts.id = rel.object_id
INNER JOINwpp9_termsas terms
ON rel.term_taxonomy_id = terms.term_id
WHERE posts.post_type='lp_course'
AND terms.slug LIKE 'page-%'
ORDER BY SUBSTR(terms.slug,6,2)+0;I used only the columns necessary to prove the theory.
Brianvu-tp,
No worries! I am on to the query part now and need some further clues. It’s a bit hard to pull out the full query with all the joins but my intended functionality based on the tag sort option is this:
SELECT * FROM wpp9_terms
WHERE slug LIKE 'page-%'
ORDER BY SUBSTR(slug,6,2)+0;
--note str to num coercion to get 1 before 10, etc...Which produces the ordered list of tags based on the prefix “page-“:
| term_id | name | slug | term_group |
|---------|-----------|---------|------------|
| 270 | Page: #3 | page-3 | 0 |
| 269 | Page: #4 | page-4 | 0 |
| 271 | Page: #6 | page-6 | 0 |
| 277 | Page: #7 | page-7 | 0 |
| 261 | Page: #8 | page-8 | 0 |
| 263 | Page: #9 | page-9 | 0 |
| 265 | Page: #10 | page-10 | 0 |
| 268 | Page: #12 | page-12 | 0 |
| 280 | Page: #14 | page-14 | 0 |
| 283 | Page: #15 | page-15 | 0 |
| 337 | Page: #16 | page-16 | 0 |
| 274 | Page: #17 | page-17 | 0 |
| 336 | Page: #18 | page-18 | 0 |
| 333 | Page: #19 | page-19 | 0 |
| 338 | Page: #20 | page-20 | 0 |
| 335 | Page: #21 | page-21 | 0 |
| 339 | Page: #22 | page-22 | 0 |
| 106 | Page: #23 | page-23 | 0 |
| 287 | Page: #24 | page-24 | 0 |
| 289 | Page: #26 | page-26 | 0 |
| 290 | Page: #27 | page-27 | 0 |This is what would order the courses output when sorting on the new page number option. I think I see where to hook the order by (inc/Models/Courses.php: function get_courses) but I think there is more setup that needs to happen b/c simply adding a switch statement:
case 'tag_ids':
$filter->order_by = $filter->tag_ids;
$filter->order = 'ASC';
break;doesn’t achieve anything but a ‘no records found’…
Thanks again for your help,
John- This reply was modified 1 year, 4 months ago by John.
For anyone following along in the future, I got the new option added and the pricing ones removed (since all our courses are free) using the hook:
function oht_create_new_tag_sort_filter( $arr ) {
$arr = array(
//New sort option
'tags' => 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 $arr;
}
add_filter( 'learn-press/courses/order-by/values', 'oht_create_new_tag_sort_filter', 10, 1 );Let me know if this isn’t what you had in mind. I will look at the query hook when I get more time and report back.
Thanks for your support!
JohnHi again, so I got this code implemented starting at line 519:
public function html_order_by( string $default_value = 'post_date' ): string {
$html_wrapper = [
'<div class="courses-order-by-wrapper">' => '</div>',
];
$values = apply_filters(
'learn-press/courses/order-by/values',
[
'tags' => esc_html__( 'Page Number', 'learnpress' ),and that has added the option in the dropdown – great!
Sorry to be dense, but I don’t see where a query is built other than for the html_count_students() function which has some SQL for getting the total students of a given category. Where do I hook to modify the query which is I assume being run in the render_courses function to add the new tag order by requirement?Thanks for your support!
Thank you Brianvu-tp! I will let you know if I run into any issues.
Best,
JohnHi and yes – my video courses correspond to specific pages in a companion book. I have tagged each course with that page number. It would be therefore nice to be able to sort the courses based on the page number so students can easily find a corresponding video while referencing the book. I hope that makes sense…
I found where I can add an option to the dropdown, but haven’t been able to discover the code where the query to the database is taking place when someone clicks on the sort option.
Thanks again for your time,
JohnHi,
That’s good but I have already got tags in the filter. What I want is to add one to the sort which is not in the widget, but in the dropdown, on the actual page (not the sidebar) under the title, next to the switch to grid/list toggle. Does that make sense?Many thanks,
JohnDear Brianvu-tp,
Thanks for the response. We are using Astra (not Pro)…
Best,
JohnHello and thanks for the reply! To clarify further I was still wanting the filter widget but just not the search bar included in it since there already is one on the main part of the page:

After working further I like the search included in the widget better since it is more functional so I removed the search bar under All Courses heading instead with this CSS:
.search-courses {
visibility: hidden;
}Problem solved.
Best,
Johnp.s: Since this is on the All Courses page and not a sidebar in a course page, the text might read better as Search Courses imho…
- This reply was modified 1 year, 5 months ago by John. Reason: additional suggestion

Thanks for the follow-up, yes I have accomplished this with the CSS given. The screenshot above is what is required. The actual course header then looks like this:

Just out of the box the filter looks like this with hierarchies:

And the course header then becomes this:

Normally I wouldn’t repeat the key in the child but in the course header it wouldn’t make sense to just see C or D and searching for example. I hope this clears it up for you.
Like I say this is fixed with a few simple CSS tricks but if you look at say the Filter Everything plugin they have this worked out nicely…
Thanks for your support.
John