-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Editor: Add option to ignore sticky posts in Query block #8265
base: trunk
Are you sure you want to change the base?
Editor: Add option to ignore sticky posts in Query block #8265
Conversation
Introduce a new `ignore` value for the `sticky` query argument. When this value is used, the query won't prepend sticky posts at the top; instead, it will display them in the natural order of the query.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of nit picks inline but this looks good to me.
I've taken the liberty of pushing some tests to your branch to ensure each of the settings work as expected. On trunk the tests fail, on this branch they pass.
The trunk
results are:
$ ./vendor/bin/phpunit --group 62908
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 9.6.21 by Sebastian Bergmann and contributors.
Warning: Your XML configuration validates against a deprecated schema.
Suggestion: Migrate your XML configuration using "--migrate-configuration"!
..F 3 / 3 (100%)
Time: 00:00.203, Memory: 193.00 MB
There was 1 failure:
1) Tests_Blocks_wpBlock::test_build_query_vars_from_block_query_ignore_sticky_posts
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
'post_type' => 'post'
'order' => 'DESC'
'orderby' => 'date'
- 'post__not_in' => Array &1 ()
+ 'post__not_in' => Array &1 (
+ 0 => 21
+ )
'tax_query' => Array &2 ()
- 'ignore_sticky_posts' => 1
)
/vagrant/wordpress-develop/tests/phpunit/tests/blocks/wpBlock.php:877
FAILURES!
Tests: 3, Assertions: 8, Failures: 1.
Thanks for pushing the tests, @peterwilsoncc 🙇 |
Appart from the couple wpcs issues reported by Peter this looks good to me 👍 Concerning the |
@peterwilsoncc, @audrasjb let me know if this is good to commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Mamaduka 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks George, this looks good for commit.
Introduce a new
ignore
value for thesticky
query argument. When this value is used, the query will not prepend sticky posts at the top but display them in the natural order.Related: #8228
Gutenberg PR: WordPress/gutenberg#69057
Trac ticket: https://core.trac.wordpress.org/ticket/62908#ticket
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.