-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
query-loop block: Run the main query when queryId is not set (#25377) #26825
Conversation
Het @bobbingwide - thanks for exploring this! I think that a solution like this: #25377 (comment), proposed by @aristath, with query merging etc.. seems to be enough for server-side, as it will still work with The main problem that needs solving regarding the context, includes showing the proper results in the client side as well. I've started exploring this as well, with no clear proposal yet. The |
Hi @ntsekouras. I don't understand what you're saying. What do you mean by "showing the proper results in the client side"? |
Query block is meant to be used for Makes sense? If not please tell me and I'll try to rephrase. |
The challenge is for the Site Editor to know which main queries are going to be handled by the template and to simulate those queries. But how would I submitted this PR since I wanted to make progress with my own experimental theme. |
Yeah, I know this is quite a problem... I don't have a clear solution yet myself. Nevertheless, I believe a solution should involve clear decisions on that first and then handle the front-end as well. Another problem with handling this in |
With the code I've delivered the In this example the content being displayed is The template being used is
and the
Note: the use of the The same template file is used to display the It would be nice if the After all, this is still experimental. |
You have to start from somewhere. I chose to get the server side logic for the front end to work.
I have a theme where the main blog page is currently implemented using the main query but has three separate display formats:
The pagination applies to the whole page. |
Thanks so much for your efforts here @bobbingwide, really appreciate it! I'll close this PR now though, as this has been implemented here: #27128 |
Description
core/query-post
block is not an inner post ofcore/query
.$block->context['queryId']
is not set.The function to run the main query is basically the same loop as previously developed but using standard loop functions
have_posts()
,the_post()
andget_post()
to process the main query andWP_block->render()
to render each posts content.This solution supports standard pagination.
How has this been tested?
index.html
I created block posts with different categories, tags and dates:
and clicked in the links available to display categories or tags or months.
Screenshots
Types of changes
Fixes #25377
I imagine that some developer and user documentation will be required to enable other developers and users
to understand how to construct templates.
The
core/query
block will be needed when something other than the main query is to be run.Checklist:
My code is tested.
My code follows the WordPress code style.
My code follows the accessibility standards.
My code has proper inline documentation.
I've included developer documentation if appropriate.
I've updated all React Native files affected by any refactorings/renamings in this PR.
I've not PHPunit tested the code. I don't have a
wp-env
environmentI expect there will be coding standard violations. I can't run lint and I don't trust my PhpStorm's Coding standards configuration one inch.
The same solution ( testing queryId ) can be used to improve the 'core/query-pagination' block.