Overview
The [simple_post_like] shortcode lets you place the like button anywhere WordPress renders shortcodes — post content, page content, widget areas, page builders, and PHP templates via do_shortcode(). It works independently of the auto-injection setting, so you can use shortcodes even when auto injection is enabled.
Basic Usage
Place the shortcode inside any post or page content:
[simple_post_like]
With no attributes, the shortcode renders the like button for the current post using the global display style set in Settings.
Attributes
post_id
Type: integer Default: current post ID
Renders the like button for a specific post by ID. Useful when you want to show a like button for a different post than the one currently being viewed — for example, in a “related posts” section or a custom template.
[simple_post_like post_id="123"]
If the post ID does not exist or belongs to a post type that is not enabled in Settings, the shortcode returns an empty string silently.
style
Type: string Default: global display style from Settings
Overrides the global display style for this instance only. Does not affect other like buttons on the same page or the global setting.
[simple_post_like style="button_default"]
[simple_post_like style="icon_counter"]
[simple_post_like style="icon_only"]
| Value | Description |
|---|---|
button_default | Full button with icon, label, and like count |
icon_counter | Compact icon with count beside it |
icon_only | Minimal circle icon, no count visible |
If an unrecognised value is passed, the shortcode falls back to the global style setting.
Combining Attributes
Attributes can be combined freely:
[simple_post_like post_id="123" style="icon_only"]
[simple_post_like post_id="456" style="icon_counter"]
Usage in Page Builders
The shortcode works in any page builder that supports WordPress shortcodes — Elementor, Beaver Builder, WPBakery, Divi, and others. Paste [simple_post_like] into a shortcode block or text module as you would any other shortcode.
In Elementor, use the Shortcode widget. In Divi, use the Code module.
Usage in Widget Areas
Add a Shortcode widget or a Text widget to any widget area and paste the shortcode inside. This is useful for placing a like button in a sidebar or footer for the currently viewed post.
Note that post_id defaults to the current post ID — in a sidebar context this works correctly as long as the sidebar is rendered inside the main post loop. If the sidebar is rendered outside the loop, pass an explicit post_id.
Usage in PHP Templates
Call do_shortcode() to render the like button from a PHP template file:
php
echo do_shortcode( '[simple_post_like]' );
With attributes:
php
echo do_shortcode( '[simple_post_like style="icon_counter"]' );
For a specific post:
php
echo do_shortcode( '[simple_post_like post_id="' . get_the_ID() . '"]' );
For a cleaner approach in template files, see PHP Template Usage which documents the direct PHP function available for template developers.
Shortcode and Auto Injection Together
If auto injection is enabled and you also place a shortcode inside the same post’s content, the button will appear twice on that post. To avoid this:
- Disable auto injection globally and use shortcodes only, or
- Set the single post injection position to None and use shortcodes for manual control on individual posts
Next Steps
- PHP Template Usage — render the button directly from template files
- Display Styles — visual reference for all three styles
- Auto Injection — automatic placement via
the_contentfilter