=== Query Loop Exclude Current Post ===
Contributors: smallplugins, oncecoupled, zafark
Donate link: https://smallplugins.com/
Tags: query loop, query block, related posts, exclude, current post
Requires at least: 5.8.3
Requires PHP: 5.6
Tested up to: 7.1
Stable tag: 0.0.8
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Keep the post someone is reading out of your Query Loops, so related-post sections never repeat the page they're on.

== Description ==

A "You might also like" section at the bottom of a post usually pulls from the same category as the post itself, which means the post someone is already reading often shows up in its own related list.

This plugin adds a single toggle to the Query Loop block called **Exclude Current Post**. Switch it on and that loop leaves out whichever post is being viewed, so the list always shows something else.

**How it works**

* Select a Query Loop block, open the block settings sidebar, and turn on **Exclude Current Post**.
* The setting belongs to that one block, so you can have several Query Loops on the same page with the toggle on for some and off for others.
* The post is removed before the posts-per-page limit is applied, so a loop set to show three posts still shows three, not two.
* It works on the front end and in the editor preview, so what you see while building the page matches what visitors get.

**No settings page**

There is nothing to configure. The plugin adds the one toggle to the Query Loop block and does nothing else.

**Works alongside post selection plugins**

If another plugin has already narrowed a loop down to a hand-picked set of posts, the current post is removed from that set rather than being ignored.

== Installation ==

1. In your WordPress admin, go to **Plugins > Add New** and search for "Query Loop Exclude Current Post".
2. Click **Install Now**, then **Activate**.
3. Edit any post, page or template containing a Query Loop block, select the block, and turn on **Exclude Current Post** in the block settings sidebar.

To install manually, upload the plugin folder to `/wp-content/plugins/` and activate it from the Plugins screen.

== Frequently Asked Questions ==

= Where is the setting? =

Select a Query Loop block in the editor and open the settings sidebar on the right. There is a panel called **Exclude Current Post** with a single toggle inside it.

= I do not see the toggle on my Query Loop block =

The toggle only appears when the Query Loop uses its own query. If **Inherit query from template** is switched on, the block is showing the page's main query, such as an archive or search results, where there is no single post being viewed to exclude. Switch inheriting off and the toggle appears.

= Does it affect the other Query Loops on the page? =

No. The setting is stored on each block separately, so turning it on for one loop leaves every other loop on the page exactly as it was.

= Will my related posts section end up one short? =

No. The current post is excluded before the posts-per-page limit is applied, so a loop set to show three posts shows three other posts.

= Does it work with custom post types? =

Yes. The plugin does not care which post type a loop is querying.

= Does it work with the Classic Editor or with shortcodes? =

No. This plugin extends the Query Loop block, so it needs the block editor.

= Does it slow my site down? =

No. It adds the current post's ID to the query's exclusion list, which is a normal part of how WordPress builds a query.

== Screenshots ==

1. A related posts Query Loop on an article about Easy Pasta Bake. Left as it is, the loop lists the post the reader is already on. With Exclude Current Post switched on, only the other recipes remain.

== External services ==

This plugin bundles the Small Plugins SDK, which adds a **Small Plugins** screen to your WordPress admin listing our other plugins.

When an administrator opens that screen, the SDK requests the plugin list from smallplugins.com:

* **Endpoint:** https://smallplugins.com/wp-json/small-plugins/v1/plugins
* **When:** only while the Small Plugins admin screen is being viewed. The response is cached, so the request is not repeated on every page load.
* **What is sent:** no personal data and no site content. The request carries the SDK version and your site's home URL in the User-Agent header.
* **What is received:** the list of Small Plugins products shown on that screen.

No request is made from the front end of your site, and excluding the current post from a Query Loop works whether or not this request succeeds.

This service is provided by Small Plugins. Terms and conditions: https://www.smallplugins.com/legal/terms-and-conditions/ Privacy policy: https://www.smallplugins.com/legal/privacy-policy/

== Changelog ==

= 0.0.8 =
* Replaced the Freemius framework with the Small Plugins SDK.
* Tested with WordPress 7.1.

= 0.0.7 =
* Updated the bundled framework and WordPress compatibility.

= 0.0.6 =
* Fixed the exclusion being ignored when another plugin had already limited a loop to a hand-picked set of posts.

= 0.0.5 =
* Maintenance update.
