This guide takes you from an empty editor to a working snippet on your site. It takes about five minutes and touches every part of the plugin you will use daily: the code tabs, the sidebar, the Conditions tab, the shortcode and the Gutenberg block.
Everything on this page works in the free WP Coder and in WP Coder Pro.
Before you start: install the plugin — see Install and Activate. With WP Coder Pro, activate your licence too: without it Pro prints nothing on the site.
1. Create a snippet#
Go to WP Coder → Add new (the menu is called WP Coder Pro in Pro) and give the snippet a title, for example Announcement bar. The title is only for you — it appears in All Codes and in error reports.
2. Write the code#
The editor has a tab for each language. You never need wrapper tags: no <style>, <script> or <?php.
HTML tab
<div class="announce">
<strong>New:</strong> the spring collection is here. <a href="/shop/">Have a look</a>
</div>
CSS tab
.announce {
padding: 12px 16px;
background: #0b57d0;
color: #fff;
text-align: center;
}
.announce a { color: #fff; text-decoration: underline; }
Turn on Live Preview in the HTML tab to see the result while you type.
3. Decide where it appears#
You have three ways to place a snippet. Use whichever fits:
| Way | How | Best for |
|---|---|---|
| Automatically | Conditions tab → Display Everywhere and a Location (head, after <body> opens, before/after the post content, before </body>). Only on chosen posts, pages or archives: Display Rules PRO. |
Site-wide code, tracking, banners |
| Shortcode | Copy the shortcode from the sidebar, e.g. [wp_code id="12"], and paste it into a post, page or widget (it appears in the sidebar after the first save). |
One place in the content |
| Gutenberg block | In the block editor add the WP Coder Snippet block and enter the snippet ID. | Editors who work visually |
For this example open Conditions, set Display to Everywhere and Location to After <body> opens.
A snippet whose Display is Shortcode (the default) is shortcode-only: it does nothing until you place its shortcode or block.
4. Save#
Press Save in the bar at the bottom of the window (or Ctrl/Cmd + S). New snippets are Active by default — the switch is in the sidebar.
Open any page of the site: the bar is there.
5. Test before everyone sees it#
Not sure the code is right? Switch on Test mode in the sidebar before saving. The snippet then runs only for logged-in administrators — visitors see nothing until you switch it off.
Make it editable: your first block with fields#
Snippets become really useful when editors can change their content without touching code.
- Open the Attributes tab and add two rows:
message(type Text) andlink(type URL/Link). - In the HTML tab replace the fixed text with placeholders:
<div class="announce">{{$message}} <a href="{{$link}}">Learn more</a></div> - Set Display back to Shortcode (so the snippet is shortcode-only) and save.
- In a post, add the WP Coder Snippet block and choose the snippet: the block sidebar now shows a field for message and one for link.
The same values work in a shortcode: [wp_code id="12" message="Sale ends Friday" link="/pricing/"].
Where to go next#
- All Codes — manage, tag, pin and switch snippets in bulk.
- Attributes & Block Fields — 8 field types, 20 in WP Coder Pro.
- Conditions — show a snippet only to some visitors, devices or dates. PRO
- Loop Logic —
<If>and<Loop>in your HTML. PRO - WP Coder and WP Coder Pro — what each plugin includes.
- Tutorials — complete, real-world examples.