How to sort LearnPress courses by price in WordPress?

Hey everyone,

I’m new to WordPress and working with the LearnPress plugin. I’m trying to figure out how to change the sorting on the ‘All Courses’ page. Right now, it’s showing courses by date, but I want them to appear from lowest to highest price.

I’ve tried looking for the right hook to use, but I’m not having any luck. Can someone point me in the right direction? What’s the best way to modify the course order? Any tips or code snippets would be super helpful.

Thanks in advance for your help! I really appreciate it.

hey swimmin dolphin! i’ve been there too. sorting by price can be tricky. have you tried adding custom code to your functions.php file? there’s a cool function that uses ‘pre_get_posts’ to change the query. it sorts courses from cheapest to priciest. lemme know if you want more details!

Hey SwimmingDolphin! :dolphin:

I totally get your struggle with sorting courses by price. It can be a bit tricky when you’re new to WordPress and LearnPress. Have you tried playing around with any custom code yet?

I’m curious - what made you want to sort by price instead of date? Are you running any special promotions or trying to highlight your budget-friendly options?

If you’re open to a bit of coding, there’s a neat little function you can add to your theme’s functions.php file. It hooks into the ‘pre_get_posts’ action and tweaks the query to sort by price. I’d be happy to share it if you’re interested!

What kind of courses are you offering, by the way? I’m always excited to hear about new learning opportunities! :blush:

Let me know if you need any more help or just want to chat about your WordPress journey. We’ve all been newbies at some point!