Skip to content

Query loop addition: sibling post/page (omit current post-id) #39192

@Humanify-nl

Description

@Humanify-nl

What problem does this address?

The query loop block is getting better and better, especially with the ability to use patterns for the grids.

One thing I still miss is to be able to omit the current page/post from the query. I want to show page siblings, or related posts under a single-post for example.

Or maybe I am unable to find it?

A use case would be to:

  • Add a query loop block in a template-part (.after-entry or something) and assign it to the single.html template.
  • Make the query loop display 'post' as post type, and omit the current post.

This is heavy used method in blog websites, to show only related posts without the current.

What is your proposed solution?

Related posts
Possibly within the filters part in the inspector controls:

  • A checkbox labeled 'don't show current post in loop'. 'post__not_in' => [ get_the_id() ],

Page siblings
I'm aware this is more complicated (possibly 'custom blocks realm') but maybe in the future.

When 'page' is chosen as post type in the query loop, a filter should show to 'only show siblings'

Not unlike the old query param. 'parent' => get_the_id(),

  • When no parent exists, it should output a message like 'no current parent', and on the front it should be omitted.
  • One could think of an option to select a page parent manually, and only display those children.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions