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

Adds filter to control max number of posts in query block #205

Merged
merged 7 commits into from
Sep 4, 2024

Conversation

willowCeleste
Copy link
Contributor

@willowCeleste willowCeleste commented Jul 17, 2024

This adds a filter that allows a dev to control the max number of posts allowed in the query block. I removed the old hardcoded attribute maxNumberOfPosts and replaced it with a new value which is passed into the block via wp_localize_script.

Fixes #114

Copy link
Contributor

@mboynes mboynes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is 💯.

One outstanding question on this though, that I can't answer but maybe @mogmarsh can: by removing the attribute we eliminate the opportunity to add a UI control for this value. Is that OK? Is that something that would be valuable?

blocks/query/index.php Outdated Show resolved Hide resolved
Co-authored-by: Greg Marshall <[email protected]>
@mogmarsh
Copy link
Collaborator

@mboynes @willowCeleste
The original thought behind this was that a developer could set the maxNumberOfPosts and minNumberOfPosts in code - possibly in a template or a block theme, etc. and the end user would not see the attribute (unless they went into code view), but would be restricted in how many posts they could select on the front end.

For instance, the developer could say "you can have between 3 and 5 posts in this particular location", which gives the end user some flexibility, but not full control. If the minimum and maximum are set to the same number, the end user does not get any control, the range selector is not displayed.

I wonder if maybe we can leave support for maxNumberOfPosts and minNumberOfPosts but instead of setting the default value of maxNumberOfPosts to 10 we use the new localized value? I think that would allow for the original functionality, but also allow for a sitewide max.

@kevinfodness
Copy link
Member

imo I'd rather not have the "invisible setting" and go with a sitewide max, and allow flexibility in use of the blocks.

blocks/query/index.php Outdated Show resolved Hide resolved
@kevinfodness kevinfodness merged commit 080fc12 into develop Sep 4, 2024
5 checks passed
@kevinfodness kevinfodness deleted the feature/TECH-93/filterable-max-posts branch September 4, 2024 16:43
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

Successfully merging this pull request may close these issues.

Make Max Number of Posts Filterable
4 participants