Post Types Query Block is a WordPress plugin which add a new Gutenberg block. It allows you to query post types and offers different options to customize the display.
By default, WordPress Gutenberg offers a Latest Posts block to display the recent posts but it does not include the custom post types or even the pages. So, I decide to create my own block with some settings to make it more reusable.
With Post Types Query Block, you can choose:
- one post type to display among "Posts", "Pages", "Media" and your custom post types.
- the number of posts to display.
- the order ("Title", "Publication date", "Update date", "Author").
- to filter by author, categories and tags.
- the information you want to display (dates, author, featured image, excerpt) with or without label and you can even rewrite the labels.
- the layout (list or grid) and some customization (no bullet lists or the number of grid columns).
You can use Composer to install this plugin as a dependency if you use custom installers:
{
"require": {
"armandphilippot/post-types-query-block": "dev-main"
}
"repositories": [{
"type": "git",
"url": "git@github.com:ArmandPhilippot/post-types-query.git"
}]
You can specify the version by adding the corresponding tag: dev-main#v1.0.0
.
You can download this plugin on Github/Gitlab, then extract it in /wp-content/plugins/
directory.
- Navigate to the "Plugins" dashboard page and click on "Activate".
- Choose "Post Types Query Block" inside Gutenberg Editor to add a new block.
- Configure the settings in the sidebar and choose the layout with the toolbar buttons.
These screenshots were taken with the "Twenty Twenty-One" theme of WordPress. I just made an adjustment to the meta since I use description list to display them and this theme use a padding-left
with dd
.
List Preview | Grid Preview |
---|---|
Currently, the block is available in English and in French.
If you want to provide another translation for the plugin, any pull request is welcome. Likewise, if some words are misused in English, I accept the corrections. It's not my native language.
You can use wp-cli
to generate a new POT file (wp i18n make-pot
) then to convert it in JSON (wp i18n make-json
). However, it is not working for me. It does not allow me to extract JS strings with make-pot
and the make-json
command output multiple files... it is not convenient.
So, you can process like me with Poedit and po2json (the last one is already present in package.json
).
- Copy
languages/PTQBlock.pot
and rename it tolanguages/PTQBlock-{your-locale}.po
. - Use the tool you want to provide translations inside the
.po
file. - Convert the
.po
file to.json
withpo2json
by using thejed
format.
Example:
./node_modules/.bin/po2json languages/PTQBlock-fr_FR.po languages/PTQBlock-fr_FR-ptqblock-i18n.json -f jed
This project is open source and available under the GPL v2 or later License.