Query Loop Post Selector

Hand-pick which posts a Query Loop shows, in the order you choose.

Lauren Gray Avatar

Query Loop Post Selector lets you hand-pick exactly which posts a core Query Loop block shows, in the order you pick them. Search by title or by post ID, for whatever post type the Query Loop is set to.

Before you start

  • WordPress 5.8 or later
  • PHP 5.6 or later
  • The block editor. The plugin adds a panel to the core Query Loop block, so there are no other plugins to install.

Install

  1. In your WordPress dashboard, go to Plugins → Add New Plugin.
  2. Click Upload Plugin.
  3. Choose the plugin zip file.
  4. Click Install Now.
  5. Click Activate.

There’s no settings page. Everything happens inside the Query Loop block.

How to use

Pick the posts a Query Loop shows

  1. Add a Query Loop block, or select one you already have.
  2. Make sure the Query Loop isn’t set to inherit its query from the template. The plugin’s panel only appears for a custom query.
  3. Choose the post type you want in the Query Loop’s own settings.
  4. In the block settings sidebar, open the Selective Posts panel.
  5. Click the field (it’s labeled with the post type, like Post or Page) and start typing a title. To find one specific item, type its ID number instead.
  6. Click a suggestion to add it. Each suggestion shows the title and its ID, so posts with similar titles are easy to tell apart.
  7. Keep adding posts. They show up in the loop in the order you add them.
  8. Save or update the page and check it on the front end.

Remove a post from the selection

Selected posts appear as tokens in the field, written as the title followed by its ID, like “My Post (ID: 42)”. Remove a token and the post drops out of the loop. Remove them all and the Query Loop goes back to its normal query.

Block options

The plugin adds one panel, Selective Posts, to the Query Loop block settings.

  • Post type field (labeled with the Query Loop’s post type, placeholder text Select plus the post type): search and pick the items to show. Empty by default, which means the Query Loop behaves normally.

A few things to know about how it works:

  • Order follows your picks. When any posts are selected, the Query Loop’s order setting is replaced by the order you selected them in, both in the editor and on the front end.
  • Items per page still applies. The plugin doesn’t change the Query Loop’s items-per-page number, so if you pick more posts than that number, only the first ones show.
  • Changing the post type clears your picks. Switching the Query Loop’s post type, or turning on template inheritance, empties the selection.
  • The panel hides when the query is inherited. If the Query Loop inherits its query from the template, the Selective Posts panel isn’t shown.

The Query Loop’s other filters still apply. A selected post that doesn’t match the loop’s categories, author, keyword or other filters won’t show. To show exactly your picks, clear those filters.

Developer reference

Coming soon: the hooks, filters and functions you can use with this plugin from your theme or a code snippet.

FAQs

Do I need any other plugins for this to work?

No. It extends the core WordPress Query Loop block and doesn’t depend on anything else.

Does this work with custom post types?

Yes. The selector searches whichever post type the Query Loop is set to, including custom post types.

Can I search by post ID?

Yes. Type a number into the field and it looks up the item with that ID instead of searching titles.