Enforce Cornerstone archive layout over a shortcode/plugin generated loop inside a page?

I created an archive layout for the LiferLMS custom post type “course.” In the WooCommerce dashboard, there’s a “My Courses” tab from LifterLMS that displays all the courses the current user is enrolled in. Unfortunately, it uses a design from Lifter. I would like to enforce my Cornerstone archive layout here – including pagination. Is there a way to do this?

Thanks to the support team here, I was able to build an archive layout that only displays enrolled courses. However, if I create it with a Looper provider and then integrate “My Courses” into the dashboard instead of the original LiferLMS, there’s no pagination, and if “-1” (as the number) exceeds 100 courses, the page takes forever to load – so this isn’t practical. Since pagination only works without a provider, I want to somehow get my archive layout onto the my-courses endpoint in the WC dashboard.

Alternatively:
There’s also a shortcode within LiferLMS [lifterlms_courses mine=enrolled] that generates a loop of enrolled courses on the page where it was added. Is there a way to force the Cornerstone archive layout for this loop? So, basically, page xy with the shortcode [lifterlms_courses mine=enrolled] and the archive layout applied to this page?

Thanks for suggestions.

Hi Daniel,

Thanks for reaching out.
For now, the pagination works only with a few Pre-defined archive layouts. I would request you use any of the Pre Define Archive Layout and check if the pagination works. If that works, I would suggest you change the structure and style to match your design.
On the alternative solution, you can add the shortcode to any page and create a Single Layout to assign to that page.

Hope it helps.
Thanks

Thanks for your quick answer!

I believe it’s sadly not helping in my case. I would love to use the pre-defined archives, but I’ve got no idea how to use for my case because there’s no archive for enrolled courses. So I already tried this approach: Adding a new tag calles “my courses” to ALL courses to get a taxonomy archive for this “my courses”. Build my layout (without looper provider of course) for this archive including pagination. Then set condition of Post element to is-enrolled in dc:classes. Working but pagination is showing empty pages with the few posts that are meeting the criteria scattered around the pagination pages.

Other approach was building a single page with looper provider and looper consumer but as you know and said: pagination is not working at all in this case.

Would be great and the best solution for may Pro users if you could implement a way that pagination is also possible to use with looper consumers. Any plans on your agenda for this? Would be a BIG improvement!

Your second idea add Lifter’s shortcode to a page and create a single layout isn’t understandable for me? How shoud that work? Shortcode is just loading it’s own content in it’s own Lifer ugly style inside my single page then. Or did I do/understand something wrong? Would be great if one could force a Cornerstone Layout on the loop that the shortcode is creating.

Hi Daniel,

Sorry for the confusion, I assumed that the shortcode uses the loop and generates the pagination, and that is why I suggested you use the Single Layout. You can find the way to create the pagination within the Looper Provider in the following thread, but manual settings are still needed to calculate the total page.

You can try the way described in the above thread, and let us know if you need any further help with this.

Thanks

1 Like

Thanks, looks interesting. But I don’t get it. I’ve enabled Twig (Beta) in the options and the thread just suggested to add offset in provider to {{ ( query.current_page - 1 ) * 3 }} to get the pagination to work? Sounds to easy to be true :smiley: (I used 3 because my default posts in WP is set to 3 – thread is using 9). The thread doesn’t mention anymore to do?

Thank you for the update. Aside from adding the dynamic template as the offset value, you also need to create the pagination from scratch. Please make sure that the Advanced and Debug options are enabled in Twig, then add this code in a Text element. Make sure that the Text element is inside the Looper Provider but outside the main Looper Consumer. The Text element should have its own Looper Consumer with Count set to One.

{% set current_page = query.current_page_zero + 1 | default(1) %}
{% for i in 1..looper.total_pages %}
    {% if i == current_page %}
        <span class="page current">{{ i }}</span>
    {% else %}
        <a class="page" href="https://www.site.net/test-po/accueil/page/{{ i }}">{{ i }}</a>
    {% endif %}
{% endfor %}

Make sure to adjust the URL in the href attribute with the URL of the page containing the posts.

Related thread: Recurring puzzle with Looper Providers using Query Builder (pagination)

2 Likes

Holy… it’s working!! Thank you very much! You should advertise this more often it’s to great to be hidden.
Maybe you could merge this one day with the pagination element? It would be easier for most people – and looking better. Now it’s looking simple. I have to find a way to style it.

/edit: Sadly it’s still the same problem as with my other approach: When filtering posts out by condition the pagination has a lot of empty pages where the “filtered out” posts would be and the ones not filtered out are scattered between the paginations pages. I think I have to give up on this for now.

Sorry to hear that Daniel.
We will think of other ways as well.