Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determining main query from pre_get_terms #13

Open
ssnepenthe opened this issue Oct 23, 2017 · 2 comments
Open

Determining main query from pre_get_terms #13

ssnepenthe opened this issue Oct 23, 2017 · 2 comments

Comments

@ssnepenthe
Copy link
Owner

ssnepenthe commented Oct 23, 2017

Currently it is possible to hook in at pre_get_terms to modify the query args before query is actually run, but there is no good way to guarantee that the query instance is part of the terms archive.

You can check is_terms_archive(), but it is always possible that there are other term queries being run on the same page.

Core has is_main_query( $query ) and $query->is_main_query() for WP_Query...

Maybe there could be some helpers like is_term_query(), is_main_term_query() and is_term_count_query()?

@ssnepenthe
Copy link
Owner Author

Modifying number arg complicates things...

offset is hardcoded before pre_get_terms fires which means if the user wants to modify number they have to also modify offset.

Maybe it would be possible to hook in late on pre_get_terms or on get_terms_args to automatically handle offset after everything else is finalized?

@ssnepenthe
Copy link
Owner Author

Further complicated by the fact that main query and count query are instantiated early (on parse_query) after determining that the current request looks like it is for a terms archive page but before determining that the current request actually is a terms archive page.

This means you can't check Terms_Archive\is_terms_archive() from a pre_get_terms callback...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant