May 13, 2018 at 10:33 UTC - Views: 22 #54627
Hi, on the home page of http://www.cockfield.org.uk I use Page with Posts. It has these filters: category: news, order by: date, sort order: DESC, max posts: 12.
Usually everything works fine, except that when I have a sticky post, as now, that post is removed when I add another ordinary post. When adding posts which would take me over the display limit of 12, I’ve always assumed that the date sort order would apply and only the most recent 12 would be displayed. I do clean up these posts from time to time by altering the category to ‘archive’ but I’ve never worried about whether I may have more than 12 in the new category at any one time, as I’ll always have the latest 12 which is what I want.
However I assumed that a sticky post takes precedence over the post display rules, so that in my case when I have a sticky post the max number to display is in effect 11 plus the sticky post. By experiment it seems I’m wrong. As you look at the site now the sticky post is there – the 1st one with the grey background. But if i add another post to the news category, it gets displayed and the sticky post is removed.
I had thought this could be due to having more than 11 posts in the news category, and so the 12th took precedence over the sticky post. But when I look at my Posts, in fact I’ve got around 50 which are in the news category (I’ve got some tidying to do). Again normally this is not an issue for me as only the latest 12 are displayed. So now I am puzzled as to what limit I am currently hitting which allows the next post to remove the sticky post, but more generally why does my sticky post come unstuck no matter how many other posts I have?!
I am running WP 4.9.5-en_GB, Weaver Xtreme Plus 3.11, Xtreme Theme Support 3.2.3
Thanks for your help.May 13, 2018 at 15:59 UTC - Views: 24 #54628
Well, you’ve uncovered the first bug in Page with Posts we’ve found in a very long time – years, perhaps.
To clarify one issue, if you specify 12 posts to show, then 12 posts will show, sticky or otherwise. This is also how the standard WordPress blog page shows when you specify maximum number of posts in the Settings:Reading menu.
But on to the bug you uncovered – the way Page with Posts works now (and it is not correct, really) is that due to limitations in the way WordPress core retrieves posts by category (as used by Page with Posts), it does not handle sticky posts very well. Weaver Xtreme has a big piece of (incorrect) code to display sticky posts, BUT – that code only finds sticky posts in each group of posts it displays. So if you specify 12 posts, it will display any sticky posts from that set of 12 posts. If there is another sticky post in a later group of posts (as demonstrated on your site), then the sticky post will be displayed at the top of that page – your site currently shows a sticky post at the top of the 1st page, and a different one on the 2nd page.
It is not clear to me that this can be fixed without causing a significant page load problem. Essentially, all post would have to be scanned twice (once to find all the sticky posts, then again for the rest.)
I will try to find a fix, but this is not high on the priority list, partly because this issue has never been reported before, partly because it is very difficult to fix. The easiest (and ugliest) fix would be to display all sticky posts (filtered as specified in the page with post options) on the first page, regardless of the number of posts per page specified, then the other posts. Later pages that had sticky posts would then not display sticky posts, resulting in some pages with fewer displayed posts than the max number of posts specified.
But all sticky posts will eventually be displayed on some page or another, but might fall off the first page as newer posts move onto it.
I’m totally surprised that this has not been discovered before, but it is also clear why our testing failed to detect it.May 14, 2018 at 04:41 UTC - Views: 15 #54635
Possible workaround for some: I use numeric dates in post titles, sort by title, and turn the post title off so it does not show. Example title: 20180513 Signup For Parade. If I have two posts of the same date I can add -1, -2 to the date to control the order. Or use an older/newer unused date as this ‘date’ is irrelevant, merely for sorting. Intuitive, no need to track another number system. Thus my ‘sticky’ title starts with 20181231 (end-of-year) and always sorts on top. At the end of the year I can update that title to 20191231, or heck put it out five years. It is the weather alert post under ‘Notices’ at http://www.WilliamsburgWV.com. Same scheme for the ‘Kudos’ category. (‘Events’ are different, handled by ‘My Calendar’ plugin. A ‘sticky’ event it is set to occur every day/all day, or else put it in a separate div before the events list starts.) Unfortunately by usurping the title field of posts for organizing I then must bother using header tags to create a title within each post. Probably too cumbersome to redo a long history of posts. Just seemed to be my easiest path at the time, use a template.May 14, 2018 at 09:01 UTC - Views: 15 #54636
I feel honoured to have found a bug, perhaps worthy of a plaque on the wall in your boiler room or something. In reality I don’t think it’s worth pursuing a fix on my account. The posts on my home page generally age over a monthly cycle of village news. 12 has proved to be about the right number of posts to show of current news; to manage that I usually modify the post category to ‘archive’ so that it’s no longer displayed but can be found with a search. So whilst I have many more than 12 posts with the news category at the moment, I very much doubt that any villager bothers to look at page 2 and beyond. I will do what I used to do and be more diligent about archiving posts so at any one time I’m left with no more than 12 in the news category. At any given time one of those might be sticky and I can’t recall a situaiton in the last couple of years when I’ve needed 2 sticky posts. Even then I can force the date of the post to make it show up 1st or 2nd in the list.
So I’m happy that I can work round the issue with no loss of capability for my site.
You must be logged in to reply to this topic.