Overview
Simple Post Like hooks into WordPress’s the_content filter to inject the like button automatically — no template edits, no shortcodes required. You control where it appears from Settings → Simple Post Like → Auto Injection.
How It Works
When a page loads and WordPress renders post content, the_content filter runs on the output. Simple Post Like hooks into this filter and appends, prepends, or wraps the like button around the content based on your position setting.
Two guards run before injection happens:
in_the_loop()must returntrue— prevents injection outside the main post loopis_main_query()must returntrue— prevents injection in secondary queries, widget areas, or customWP_Querycalls
This means the button only ever appears in the right place — the main content area of your posts — and never leaks into sidebars, footers, or custom query loops.
Master Toggle
The Auto Injection toggle is the master switch for all automatic placement. When disabled, no injection happens anywhere — the button only appears where you place the [simple_post_like] shortcode manually.
Default: Enabled
When to disable:
- Your theme templates already have a dedicated spot for post actions
- You are using a page builder that manages content output independently
- You want precise shortcode-based control over every placement
- You are building a headless or decoupled WordPress setup
Position on Single Posts
Controls injection placement on single post pages — any URL where is_singular() returns true for an enabled post type.
| Option | Behavior |
|---|---|
| After Content | Button injected after </p> of the last content block |
| Before Content | Button injected before the first content character |
| Before & After | Button injected at both positions |
| None | No injection on single posts — archive only if enabled |
Default: After Content
The None option is useful when you want the button on archive pages only, without it appearing on the full post page — for example, on a news site where archive cards are the primary engagement surface.
Archive Page Injection
An independent toggle that controls injection on archive pages — blog index (is_home()), category pages, tag pages, author pages, and search results — anywhere WordPress loops through posts and renders content via the_content.
Default: Enabled
When enabled, the button is injected after content on archive pages regardless of the single post position setting. Archive injection always uses the after-content position — before-content and before-and-after positions apply to single posts only.
When to disable:
- Your archive templates show only excerpts and the button feels out of place
- You are using
the_excerptinstead ofthe_contenton archive pages — in that case this toggle has no effect anyway since the hook only runs onthe_content - You want the like feature on full post pages only
Injection and Custom Post Types
Auto injection respects the Post Types setting. The button is only injected on post types you have enabled under Settings → Simple Post Like → Post Types. If a custom post type is not checked, no injection happens on its singular or archive pages regardless of the injection settings.
Shortcode vs Auto Injection
Both can be active at the same time. If auto injection is enabled and you also place a [simple_post_like] shortcode inside the same post’s content, the button will appear twice — once from the shortcode and once from the injection. To avoid this, either:
- Disable auto injection and use shortcodes only, or
- Set the injection position to None for single posts and use shortcodes on individual posts where you want manual control
Next Steps
- Guest Likes — how guest tracking works
- Shortcode Reference — manual placement with full attribute reference