Creative Andrew’s Blog

Web development articles focused on WordPress and headless applications.

How to select a single post in the query loop block?

  • Block Editor
  • WordPress

A while back, a successful blog client approached with a simple ask: a single post teaser to be inserted in her articles. This teaser, with an image and title, opens the article on click. It should look something like the image above:

"No problem," I thought, diving into the Block editor in search of solutions. Surprisingly, existing plugins fell short—they focused on related posts, not a specific one. Even on Reddit, fellow developers were grappling with a similar puzzle.

My initial attempt with the Query Loop block, tweaking post-per-page and using the keyword field, showed promise. However, the broad keyword search made it unpredictable. I often landed on incorrect results, related but not exactly what I sought.

Despite its closeness to the goal, the Query Loop block needed refinement. Inspired by a guide on extending the block, I crafted a variation—the Single Query Loop Selector. This version incorporated a search field for precise post selection:

The Single Query Loop Selector: This variation hit the mark, enabling me to curate a list of posts and choose the exact one I needed.

Creating a design pattern aligned with my client's preferences, I delivered a solution that not only pleased her but worked seamlessly.

You can now find the Single Post Query Loop Selector plugin in the official WordPress repository.

Here is a look at the open-source code:…