PHPackages                             yard/query-block - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yard/query-block

ActivePackage[Utility &amp; Helpers](/categories/utility)

yard/query-block
================

A query block for the Gutenberg editor.

v1.4.0(2mo ago)11.6k↓32.3%[2 PRs](https://github.com/yardinternet/wp-query-block/pulls)MITJavaScriptPHP ^8.2CI passing

Since May 23Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/yardinternet/wp-query-block)[ Packagist](https://packagist.org/packages/yard/query-block)[ RSS](/packages/yard-query-block/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (20)Versions (27)Used By (0)

WP Query Block
==============

[](#wp-query-block)

[![Code Style](https://github.com/yardinternet/yard-query-block/actions/workflows/format-php.yml/badge.svg?no-cache)](https://github.com/yardinternet/yard-query-block/actions/workflows/format-php.yml)[![PHPStan](https://github.com/yardinternet/yard-query-block/actions/workflows/phpstan.yml/badge.svg?no-cache)](https://github.com/yardinternet/yard-query-block/actions/workflows/phpstan.yml)[![Tests](https://github.com/yardinternet/yard-query-block/actions/workflows/run-tests.yml/badge.svg?no-cache)](https://github.com/yardinternet/yard-query-block/actions/workflows/run-tests.yml)[![Code Coverage Badge](https://github.com/yardinternet/yard-query-block/raw/badges/coverage.svg)](https://github.com/yardinternet/yard-query-block/actions/workflows/badges.yml)[![Lines of Code Badge](https://github.com/yardinternet/yard-query-block/raw/badges/lines-of-code.svg)](https://github.com/yardinternet/yard-query-block/actions/workflows/badges.yml)

An acorn package providing a "Query Block" for the Gutenberg editor.

Requirements
------------

[](#requirements)

- [Sage](https://github.com/roots/sage) &gt;= 10.0
- [Acorn](https://github.com/roots/acorn) &gt;= 4.0

Installation
------------

[](#installation)

1. Install this package with Composer:

    ```
    composer require yard/query-block
    ```
2. Run the Acorn WP-CLI command to discover this package:

    ```
    wp acorn package:discover
    ```

Usage
-----

[](#usage)

When this package is installed, you can insert the “Berichtenlijst” block in the Gutenberg editor. This block lists a series of posts based on different filter settings in the admin.

### Templates

[](#templates)

#### Override Default Template

[](#override-default-template)

A default template is included in the package. You can publish the template to your project with:

```
wp acorn vendor:publish --provider="Yard\QueryBlock\QueryBlockServiceProvider"
```

This will copy the view default.php from this package into your project at `/sage/resources/views/vendor/yard-query-block/templates/default.blade.php`. You can now modify the default template as desired.

#### Create Aditional Templates

[](#create-aditional-templates)

You can create additional templates by placing a template file in the same directory. For example:

`/sage/resources/views/vendor/yard-query-block/templates/horizontal.blade.php`

Add the template name as a comment at the top of this template file like this:

```
@php
/**
 * Template: Horizontal
 *
 * @var Illuminate\Support\Collection|Yard\Data\PostData $postDataCollection
 * @var Yard\QueryBlock\Block\BlockAttributes $attributes
 */
@endphp
```

Now, you will be able to select the template from the editor. The name of the template is displayed using the value in your docblock.

### ACF Post Object Field

[](#acf-post-object-field)

It is possible to add a connection filter to the block settings that lets you filter the available posts based on connected posts. This only works for the ACF "Post Object" field.

**Important: For this to work, the Post Object field setting "Select Multiple" must be disabled.**

All you need to do is publish `config/yard-query-block.php` and register all connections in the `connections` array. For example:

```
return [
	'connections' => [
		[
			'from' => 'news',
			'to' => 'project',
			'meta_key' => 'news_related_project',
		],
	],
];
```

Hooks
-----

[](#hooks)

### JavaScript filters

[](#javascript-filters)

#### `yard.query-inspector-config`

[](#yardquery-inspector-config)

Customize which controls are displayed in the block's inspector panel.

```
import { addFilter } from '@wordpress/hooks';

addFilter(
    'yard.query-inspector-config',
    'yard.query-inspector-config',
    ( config, attributes ) => {
        return {
            ...config,
            showPostTypeSelectControl: false,
            showNumberOfPostsRangeControl: false,
        };
    }
);
```

#### `yard.query-exclude-post-types`

[](#yardquery-exclude-post-types)

Exclude specific post types from the list of available post types.

```
import { addFilter } from '@wordpress/hooks';

addFilter(
    'yard.query-exclude-post-types',
    'yard.query-exclude-post-types',
    ( excludedPostTypes ) => {
        return [
            ...excludedPostTypes,
            'healthcare-provider',
            'location',
            'page',
        ];
    }
);
```

#### `yard.query-exclude-taxonomies`

[](#yardquery-exclude-taxonomies)

Exclude specific taxonomies from the list of available taxonomies.

```
import { addFilter } from '@wordpress/hooks';

addFilter(
    'yard.query-exclude-taxonomies',
    'yard.query-exclude-taxonomies',
    ( excludedTaxonomies ) => {
        return [ 'category', 'post_tag' ];
    }
);
```

#### `yard.query-min-number-of-posts` and `yard.query-max-number-of-posts`

[](#yardquery-min-number-of-posts-and-yardquery-max-number-of-posts)

Customize the minimum and maximum value for the posts per page range.

```
import { addFilter } from '@wordpress/hooks';

addFilter(
    'yard.query-max-number-of-posts',
    'yard.query-max-number-of-posts',
        (defaultMax, attributes) => {
        const postTypeValues = attributes.postTypes?.map((type) => type.value) || [];

        if (postTypeValues.includes('news')) {
            return 5;
        }

        if (postTypeValues.includes('healthcare-provider')) {
            return 2;
        }

        return defaultMax;
    }
);
```

#### `yard.query-post-type-select-control-is-multi`

[](#yardquery-post-type-select-control-is-multi)

Change the post type select control from multi to single select.

```
import { addFilter } from '@wordpress/hooks';

addFilter(
    'yard.query-post-type-select-control-is-multi',
    'yard.query-post-type-select-control-is-multi',
    () => false
);
```

### PHP filters

[](#php-filters)

#### `yard_query_block_post_query`

[](#yard_query_block_post_query)

Filters the Post Query before it is executed on the database.

ParametersTypeDescription$query\\Corcel\\Model\\Builder\\PostBuilderThe query object$attributes\\Yard\\QueryBlock\\Block\\BlockAttributesThe block attributesReturnTypeDescription$query\\Corcel\\Model\\Builder\\PostBuilderThe query objectExample:

```
add_filter('yard_query_block_post_query', function ($query, $attributes) {
    if (is_user_logged_in()) {
        return $query;
    }

    return $query->hasMeta('post_is_public', 'yes');
}, 10, 2);
```

About us
--------

[](#about-us)

[![banner](https://raw.githubusercontent.com/yardinternet/.github/refs/heads/main/profile/assets/small-banner-github.svg)](https://www.yard.nl/werken-bij/)

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance87

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~36 days

Recently: every ~77 days

Total

19

Last Release

68d ago

PHP version history (2 changes)1.0.0PHP ^8.1

v1.3.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/62775?v=4)[Anton Zhuravsky](/maintainers/Yard)[@yard](https://github.com/yard)

---

Top Contributors

[![SimonvanWijhe](https://avatars.githubusercontent.com/u/41121933?v=4)](https://github.com/SimonvanWijhe "SimonvanWijhe (122 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (59 commits)")[![laravdiemen](https://avatars.githubusercontent.com/u/80510718?v=4)](https://github.com/laravdiemen "laravdiemen (39 commits)")[![YvetteNikolov](https://avatars.githubusercontent.com/u/48315669?v=4)](https://github.com/YvetteNikolov "YvetteNikolov (15 commits)")[![Rovasch](https://avatars.githubusercontent.com/u/166744617?v=4)](https://github.com/Rovasch "Rovasch (4 commits)")[![FreakyWizard](https://avatars.githubusercontent.com/u/114140418?v=4)](https://github.com/FreakyWizard "FreakyWizard (3 commits)")[![ictbeheer](https://avatars.githubusercontent.com/u/14947039?v=4)](https://github.com/ictbeheer "ictbeheer (1 commits)")[![yard-bot](https://avatars.githubusercontent.com/u/66111179?v=4)](https://github.com/yard-bot "yard-bot (1 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (1 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/yard-query-block/health.svg)

```
[![Health](https://phpackages.com/badges/yard-query-block/health.svg)](https://phpackages.com/packages/yard-query-block)
```

###  Alternatives

[guava/calendar

Adds support for vkurko/calendar to Filament PHP.

298241.0k3](/packages/guava-calendar)[tonysm/rich-text-laravel

Integrates Trix content with Laravel

46577.8k1](/packages/tonysm-rich-text-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[spatie/laravel-screenshot

Take screenshots of web pages in Laravel apps

7615.9k2](/packages/spatie-laravel-screenshot)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[ymsoft/filament-money

Filament plugin for convenient storage and management of monetary fields

103.4k](/packages/ymsoft-filament-money)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
