Timeline for Why the pagination for a query modified by pre_get_posts doesn't mind the number & order of posts sorted & selected based on a custom date time field
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 29, 2018 at 0:27 | history | edited | rkoller | CC BY-SA 4.0 |
added 2135 characters in body
|
Jul 25, 2018 at 20:36 | comment | added | Tom J Nowell♦ | @rpk that's correct, next and previous posts are not based on the main query, they are their own thing | |
Jul 25, 2018 at 15:40 | comment | added | Milo | See Can the Next/Prev Post links be ordered by menu order or by a meta key? | |
Jul 25, 2018 at 15:22 | comment | added | rkoller |
I've added the is_single conditional to apply those query settings also to the query building the display of single posts. Otherwise it would rely onto the main query with differing setting (e.g. include Post 0 ). And I don't consider it an archive but the display of a single post (with single.php ). My remaining problem is just that Post 0 is included even though excluded by my query settings and mixing also the order clicking through with previous and next as already described in my initial post. :/ Guess the previous and next links are based on a different query not $query ?
|
|
Jul 25, 2018 at 15:16 | history | edited | rkoller | CC BY-SA 4.0 |
added 1391 characters in body
|
Jul 24, 2018 at 13:05 | comment | added | Tom J Nowell♦ |
hmm keep in mind that if you have pagination, you're in an archive, not a singular page, so is_single doesn't make sense. And yes if your theme is replacing the main query with its own then that complicate things immensely, however, I'm not so sure that what you're trying to do and what you want are quite the same, you talk about this as if it's pagination in an archive, but it is not. It's the next and previous post functionality, which is very different
|
|
Jul 24, 2018 at 9:06 | comment | added | rkoller |
The pre_get_post code runs and the conditional checks are correct imho. Without the is_single() conditional there is DESC instead of ASC sort order for single views. So I would say the pre_get_post code is correct. The pagination is the issue. And i suppose I don't use the main query. If i check Query Monitor I notice there is the main query and afterwards the query containing the event_start custom field. And based on the fact that I am using pre_get_post I suppose the Phlox theme isn't utilizing the main query for the display of posts on the front page :(
|
|
Jul 24, 2018 at 9:00 | comment | added | rkoller | ups sorry about the dattime. Slipped in by accident. dattime I used in my sandbox installation and event_start I chose for demonstration purposes here on the site instead. But just forgot to update the code in that direction. Sorry! Did now. | |
Jul 24, 2018 at 8:58 | history | edited | rkoller | CC BY-SA 4.0 |
added 8 characters in body
|
S Jul 24, 2018 at 6:45 | history | suggested | junkrig | CC BY-SA 4.0 |
corrected spelling and grammar
|
Jul 24, 2018 at 4:55 | review | Suggested edits | |||
S Jul 24, 2018 at 6:45 | |||||
Jul 24, 2018 at 2:10 | comment | added | Tom J Nowell♦ |
What is the meta dattime ? Your question indicates that the data is stored in a field named event_start . Have you confirmed that your pre_get_posts code runs and that your conditional checks are correct? I would also note that your fix for custom loops is unnecessary because you are not using custom loops. You're instead modifying the main query, and so the fix is not necessary and may actually cause unrelated issues in some circumstances
|
|
Jul 24, 2018 at 0:35 | history | asked | rkoller | CC BY-SA 4.0 |