A WordPress plugin that adds a Show only terms of the current post option to Terms Query blocks.
When enabled, a Terms Query block displays only terms assigned to the post currently being viewed. The editor preview and rendered block output use the same filtering behavior.
- WordPress 6.1 or later
- PHP 8.1 or later
Install the plugin with Composer:
composer require ralfhortt/current-post-terms-queryAlternatively, download or clone this repository into wp-content/plugins/current-post-terms-query.
If you are building from source, install the JavaScript dependencies:
npm installBuild the editor assets:
npm run buildFinally, activate Current Post Terms Query in WordPress.
- Add a Terms Query block to a template or post.
- Select a taxonomy.
- Enable Show only terms of the current post in the block settings.
If the Terms Query has configured included term IDs, the result is limited to the intersection of those IDs and the current post's terms.
In the Site Editor, the preview skips template and template-part editing contexts so it does not treat the template itself as the current post. On the server, filtering only runs when an explicit postId is available in block context; template parts without post context remain unfiltered.
Build the production editor bundle:
npm run buildStart the development watcher:
npm run startThe PHP filter is implemented in src/CurrentPostTermsQueryFilter.php. Editor controls and preview behavior are implemented in src/js/editor/.
GPL-2.0-or-later. See the GNU General Public License.