Open renatoalbano opened 8 years ago
I did a workaround using
infinite_scroll_query_args
action, but i think infinite scroll should work as is in wordpress rendered page.
Yes, I believe that's the expected way of doing things to get it to work today.
How do you think we should go about this instead?
@jeherve: Yes, I believe that's the expected way of doing things to get it to work today. How do you think we should go about this instead?
I think as the infinite scroll is already receiving query_vars in ajax request it should consider what was passed. In this case, keys ending with __and
,__in
, __not_in
.
Using infinite_scroll_query_args
do redefining query_args of infinite scroll query I need to duplicate my business rules in pre_get_posts
and in infinite_scroll_query_args
actions, besides having to add some extra settings to pass to infinite_scroll_query_args
action what page is, if is is_tag()
or is_category()
and etc.
I am replying as plugin user, idk infinite scroll code base and WP_Query very well to suggest more technical answer.
cc @ethitter Happy to have your opinion on this, since you worked on infinite_scroll_query_args
.
I'm encountering probably the same issue when looking at a category archive with multiple categories, eg /category/catA+catB+catC+etc/ Only catA is considered upon loading more posts via Infinite scroll. Anyone any thoughts?
Okay. For me this fixes the problem: Adding this in function get_query_vars() in infinity.php
if (self::wp_query()->query['category_name']) {
$query_vars['category_name'] = self::wp_query()->query['category_name'];
}
But it feels quite hacky. This would be no candidate for PR would it?
This issue has been marked as stale. This happened because:
No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.
This issue still exists!
I "fixed" this issue with this snipped:
function infinite_scroll_query_object($query) { $query->set("category_name", $query->query["category_name"]); return $query; } add_filter('infinite_scroll_query_object', 'infinite_scroll_query_object', 9999);
Having a sort of similar issue which I posted in the WP support forum and was directed here (https://wordpress.org/support/topic/infinite-scroll-does-not-respect-tag-query-var/#post-15269919)
I set up a blog post filter in my theme so that you can filter posts by category or tag. I update the infiniteScroll.settings.query_args
values via Javascript when the form is filled out. This works fine for infiniteScroll.settings.query_args.category_name
but not for infiniteScroll.settings.query_args.tag
(or any other permutation of the tag query vars, e.g. tag_id, tag__in, etc).
I’ve confirmed that the XHR request is sending the correct query vars and is being received by Jetpack, but it seems to ignore tags entirely.
What I expected
When I set a custom query using
pre_get_posts
action with multiple categories or tags, for example:The posts that was rendered in page was correct filtered by categories 42, 43, 44.
When I click or scroll to load more posts through infinite scroll I expect the posts that were added to page are using 42, 43, 44 categories.
What happened instead
When I click or scroll through infinite scroll, the posts that were added to page is only from category 42, the first category which was assigned at
pre_get_posts
filter.Steps to reproduce the issue
pre_get_posts
action and set acategory__in
with theses categories ids;pre_get_posts
.More About
If you inspect javascript global variable
infiniteScroll
at page, it has thecategory__in
array with correct ids assigned atpre_get_posts
. But the keycategory_name
andcat
ininfiniteScroll.settings.query_args
has only the first category slug and id. Apparently this was correct, because it was used for backward compatibility, as was being explained in this core ticket.But I think infinite scroll query was only considering the category at
cat
orcategory_name
at query_vars and ignoringcategory__in
.I did a workaround using
infinite_scroll_query_args
action, but i think infinite scroll should work as is in wordpress rendered page.I don't tested with
tag__in
filter, but I think that has the same issue.I was using: