• Resolved wpandlpuser

    (@wpandlpuser)


    Hi!
    I tried to change the ordering of the courses from the post_date to price string so that courses will be sorted from highest price to lowest price.

    It seeems that it does not have any effect on the website and the course archive widget stays as it is

    \learnpress\inc\temaplatehooks\course\ListCoursesTemplate.php

    Is it possible that I am editing the wrong source file? Why is there no effect on the webpage?

    Version 4.2.7.8

    Thanks!

    • This topic was modified 1 year, 3 months ago by wpandlpuser.
    • This topic was modified 1 year, 3 months ago by wpandlpuser.
    • This topic was modified 1 year, 3 months ago by wpandlpuser.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support brianvu-tp

    (@briantp)

    Hi wpandlpuser,

    Thank you for reaching out!

    Regarding your question about changing the course ordering on the archive page, we’ve previously discussed this topic with another user in this support thread

    Please refer to that thread for detailed instructions and code examples on how to modify the sorting behavior. We believe you’ll find the information there helpful.

    Best regards,
    Brianvu-tp

    Thread Starter wpandlpuser

    (@wpandlpuser)

    Hi Brian,

    Many thanks for your quick view on the issue. However, I just want to default price sorting instead of post-date sorting.

    Your linked article is about adding a new sorting type.

    I have overwritten the default value in row 519 from post_date to price, but it does not have any effect on the website listing.

    Is it possible, that the code is broken?

    Plugin Support brianvu-tp

    (@briantp)

    Hi wpandlpuser,

    Thank you for your respons!

    To default the course sorting to “price” instead of “post_date”, please try adding the following code snippet to your child theme’s functions.php file:

    add_action('learn-press/courses/handle_params_for_query_courses', function($filter, $param) {
        if (empty($param['order_by'])) {
           $filter->order_by = 'price';
        }
    }, 10, 2);
    
    add_filter('learn-press/layout/list-courses/section/top', function($section_top, $courses, $settings) {
        if (!isset($settings['order_by'])) {
           $settings['order_by'] = 'price';
        }
    
        $listCoursesTemplate = LearnPress\TemplateHooks\Course\ListCoursesTemplate::instance();
    
        $section_top['order_by'] = $listCoursesTemplate->html_order_by($settings['order_by']);
    
        return $section_top;
    }, 10, 3);

    Please let us know if this resolves the issue.

    Best regards,
    Brianvu-tp

    Thread Starter wpandlpuser

    (@wpandlpuser)

    Dear Brian,
    I added this snippet to the functions.php file of my theme (EXS Energy).
    I copied it to the end of the file.

    It has resolved the issue, courses are now organized from HIGHPRICE to LOWPRICE on the course overview page.

    Many thanks for your help, I wish you all the best with developing LP.

    Plugin Support brianvu-tp

    (@briantp)

    Hi wpandlpuser,

    We are glad to hear that you found the solution useful!

    If you are satisfied with LearnPress, we would greatly appreciate it if you could leave us a 5-star review. A nice rating is a big motivation for us to keep up the hard work, and it’s really important to us.

    Thank you very much for your feedback.

    Best regards,
    Brianvu-tp

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Course ordering has no impact’ is closed to new replies.