Loop pagination breaks when a shortcode is placed inside the loop

Hi!

Following of this topic but with a different specific issue:

For memo, this is a Posts loop fetching Posts IDs from an AF Relationship.
It’s filtered by Taxonomy terms and paged to display Posts by 5.

When i output a simple field, the pagination shows up and works fine:

<Loop type=output id="{Field project_outputs}" taxonomy=information_type terms=journal-article,technical-report orderby=selection order=desc paged=5>
  <Field title />
</Loop>
<PaginateButtons />

If i use a shortcode to pull more complex content, the pagination doesn’t show up:

<Loop type=output id="{Field project_outputs}" taxonomy=information_type terms=journal-article,technical-report orderby=selection order=desc paged=5>
  <Shortcode>
    [template name=project-grid]
  </Shortcode>
</Loop>
<PaginateButtons />

The pagination is partially present in the page markup – <div class="tangible-paginator-buttons"> – but numbered buttons are missing.

By the look of the loop main container markup – <div data-tangible-dynamic-module="paginator"> – it seems it grabs Posts content and paste them in this attribute value: data-tangible-paginator-target-data

So, given the complexity of my grid content, i wonder if it’s not the reason why the pagination fails?

Or, could it be the <Shortcode> tag breaking the pagination?

Thanks for your help. :wink:

I think this is just an issue with using the template shortcode within a template (see edit below), which isn’t necessary anyway since you can just use the Template tag to nest templates.

To test this out myself, I made this much simpler template:

<Loop type=post paged=2>
 <p><Field title /></p>
</Loop>
<PaginateButtons />

This worked as expected. So I made a second template that literally just contained <Field title /> and then nested that second template within the template above, which looked like this:

<Loop type=post paged=2>
 <p><Template name=title /></p>
</Loop>
<PaginateButtons />

Again, this all worked correctly and pagination worked as expected. I then gave your syntax a shot using the Shortcode tag to reference a template and you’re right, this caused my pagination to break:

<Loop type=post paged=2>
 <p><Shortcode>[template name=title]</Shortcode></p>
</Loop>
<PaginateButtons />

That being said, I don’t think this is an issue. Nesting templates using the shortcode is a bit of an awkward way to write things anyway when you can just use the Template tag. Let me know if this fixes things for you!

Edit: I just tested this with a different shortcode other than the template shortcode and it seems to also break the pagination. So I assume it’s not just all “complex content” that breaks pagination, but specifically shortcodes (at least I haven’t been able to spot anything else that makes the pagination buttons disappear). I’ve passed the message along to the great and powerful Eliot.

1 Like

Hi @benjamin,

Thanks much for your testing and for confirming the shortcode issue.

You’re right, no need for a <Shortcode> tag while we can directly use <Template>!
And the pagination is back in my page too.

But actually, i went the <Shortcode> way because i use either an existing L&L template or a custom PHP one, currently wrapped in a shortcode:

<Loop type=output id="{Field project_outputs}" taxonomy=information_type terms=journal-article,technical-report orderby=selection order=desc paged=5>
  <Shortcode>
    [resource_finder_posts]
  </Shortcode>
</Loop>
<PaginateButtons />

And the pagination breaks with this one.

Unfortunately, i need this PHP template, couldn’t create it with L&L because i had hit some limits (of memory).

Thanks for having passing the message to Eliot, maybe he will find something fixable. :wink:

1 Like