Thread Starter
Ojay
(@ojay)
I should also add that upon clicking the load more posts button, there are no console errors… literally nothing happens
Yea, ive been unsuccessful using a counter within the repeater templates. I’m not really sure why, but it seems to fail. Must be something to do with counter++ inside an include file.
One thing you could do is possible do the counting via javascript by using the almComplete method.
$.fn.almComplete = function(alm){
// Your on complete code goes here
}
I’ve posted this question on StackOverflow but no one has been able to help as of yet.
Thread Starter
Ojay
(@ojay)
Cool, thanks for looking in to it… do you have the Stackoverflow link? I couldn’t find it via search.
As I say, the problem isn’t really the counter. The counter works when the html being echo’d is opened and closed at the same point. You can repeatedly load more articles.
To be fair, the counter works perfectly once when displaying an open div at the top and a closing div at the bottom…
In this scenario the bug occurs when you go to load a second round of articles… you can’t load anything else. The button is just dead. No error in the console or anything. I’ve no idea why opening and closing html in this way would prevent the second load of posts?
With the js counter, I’d be having to append the div’s to the correct place within the most recently revealed div.alm-reveal… is there a baked in method to target that div?
Thanks again for your help, and if there’s anything you’d like me to try to help you debug this please ask π
Thread Starter
Ojay
(@ojay)
Ok so I’ve nailed the problem down to the use of div tags…
Below is repeater template #1…
<section>
<?php
if (!$start) {
$start = 1;
}
if ($start == 1 || $start == 5 || $start == 9 || $start == 13) {
echo '<div class="row">';
} ?>
<article class="clearfix col col-md-3" >
/// repeater html \\\
</article>
<?php
if ($start == 4 || $start == 8 || $start == 12 || $start == 16) {
echo '</div>';
}
$start++;
?>
</section>
This works perfectly in that you can click the load more button as many times as you like and posts will be loaded.
Repeater template #2
<div>
<?php
if (!$start) {
$start = 1;
}
if ($start == 1 || $start == 5 || $start == 9 || $start == 13) {
echo '<div class="row">';
} ?>
<article class="clearfix col col-md-3" >
/// repeater html \\\
</article>
<?php
if ($start == 4 || $start == 8 || $start == 12 || $start == 16) {
echo '</div>';
}
$start++;
?>
</div>
Repeater template #2 loads one set of articles no matter how many times you click the load more button. The only difference between #1 & #2 is the section element has been replaced with divs.
The only weird thing with repeater template #1 (it also happens on #2) is that the generated html comes out looking like this…
<section>
<div class="row">
<article class="clearfix col col-md-3">
/// article html \\\
</article>
</div>
</section>
<section>
<div class="row">
<article class="clearfix col col-md-3">
/// article html \\\
</article>
<article class="clearfix col col-md-3">
/// article html \\\
</article>
<article class="clearfix col col-md-3">
/// article html \\\
</article>
<article class="clearfix col col-md-3">
/// article html \\\
</article>
</div>
</section>
So in the first <section> only one article is printed…
then everything prints as expected, until you get to the last set of what should be four articles… (not included in the html above)
this last <section> only contains 3 articles… it’s like all the articles need to be moved up 3 places.
Sorry to bombard you, but this bug is soooo strange and I really need a fix. I may have to look to doing it myself somehow, which is a shame because you’ve created such a beautiful plugin.
Thanks for any help!
That is weird… I’m not really sure how to help you out here.
I’m surprised to hear the counter is working at all, I have had no luck with this.
At one point, a long while back I was able to get it to count posts in a single loop. But as soon as I clicked Load More the counter would reset <- this actually sounds like what is happening to you.
Have you tried removing your if statements and just using a echo with the $start value? The see what happens after a load action?
Thread Starter
Ojay
(@ojay)
Yeah… without the if statements, and therefore the markup within them, the articles are loaded perfectly. The counter counts as expected, in my case to 16.
The bug only occurs when there is html that opens at the start and closes at the bottom. For example this works amazingly…
<?php
if (!isset($start)) {
$start = 1;
}
if ($start == 1 || $start == 5 || $start == 9 || $start == 13) {
echo '<p>open the .row div</p>';
}
?>
<article class="clearfix col col-md-3" >
</article>
<?php
if ($start == 4 || $start == 8 || $start == 12 || $start == 16) {
echo '<p>close the .row div</p>';
}
$start++;
?>
This is the strangest bug in the world, ever. π
F.Y.I – I’ve tried this with all my plugins deactivated… though I’m yet to try a completely clean install with twentyfourteen.
Hey,
FYI, I have solved this count issue, which may fix your repeater template issue because you won’t need to do any counting within your templates.
What I’m doing is dispatching a variables from the core ajax-load-more.php plugin file , these variables will be available in the repeater template.
The variables are $alm_page, $alm_item.
If you want access to the code, email me @ darren.cooney [at] gmail and I can get you a sample.
I will include this with Ajax Load More 2.3.0 which should be released at the end of next week.