Automatic Placement Locations Samples
- Automatically inserts the snippet based on the selected location and type.
- Supports placement in predefined locations in the admin area, frontend, or specific pages/posts.
Automatic Placement Locations
1. Global (Only for PHP Snippet)
- The PHP snippet can be placed globally, meaning it will be inserted across all pages or locations where the snippet is configured.
- Usage: This is useful for universal elements such as tracking codes, global banners, or site-wide functionality that should appear on every page.
Code Example:
This PHP snippet globally registers a custom post type with support for title, editor, thumbnail, excerpt, custom fields, and author. It is public, has an archive page, and uses the slug/custom-type
.
It also supports the REST API for block editor compatibility.
2. Admin (Admin Panel Pages)
The snippet can be placed in the WordPress admin panel, affecting how the backend of your site behaves.
2.1 Run Everywhere (All Pages)
- The snippet runs on every admin page (including the dashboard, post/page editor, settings pages, etc.).
- Usage: Ideal for global admin-related actions, like adding custom admin notices or functionality that should be available on every admin page.
Code Example:
This snippet displays a global notification message on all WordPress admin pages.
2.2 Run on Header
- The snippet runs in the header section of the admin panel.
- Usage: Use this for admin-specific styles or scripts that need to load early in the admin environment.
2.3 Run on Footer
- The snippet runs in the footer section of the admin panel.
- Usage: Ideal for scripts or analytics tracking that need to be loaded after the main content is loaded in the admin panel.
2.4 Run on Body
- The snippet is inserted directly into the body of admin pages.
- Usage: This is useful for adding admin-specific content like banners, notices, or additional widgets within the body of the admin pages.
3. Front End (Public Site Pages)
The snippet can be placed on the front end of the site, affecting how content is displayed to users ( if the theme allows ).
3.1 Run Everywhere (All Pages)
- The snippet runs on all public pages of the site (e.g., homepage, posts, pages, etc.).
- Usage: Use this for site-wide elements such as banners, global ads, or site-wide tracking/analytics.
3.2 Run on Header(if allowed)
- The snippet runs in the header section of the front-end pages.
- Usage: This is ideal for elements like top bars, navigation-related scripts, and elements that need to be loaded early.
Code Example : This snippet displays a customizable welcome banner for all users on every public page of the site. It greets logged-in users with their username and shows their last login time or a welcome message for first-time logins. For guests, it displays a general welcome message.
code output
3.3 Run on Footer(if allowed)
- The snippet runs in the footer section of the front-end pages.
- Usage: Useful for inserting scripts, tracking codes, or elements that should load after the main content of the page.
3.4 Run on Body(if allowed)
- The snippet runs directly within the body content of the page (where allowed).
- If this doesn’t work or not inserting content at the beginning of the body, your theme may not support the
wp_body_open
hook or may not implement it correctly. This hook was introduced in WordPress 5.2, so older themes may not have it. You might need to adjust the theme or use alternative methods. - Usage: You can use this for adding extra content like promo banners, widgets, or advertisements inserted within the body of the page.
4. Page, Post, Custom Post Type (Content-Specific Pages)
These placements refer to content-specific pages such as individual posts, pages, or custom post types( if the theme allows ).
4.1 Insert Before Content(if allowed)
- The snippet is inserted before the main content of the page (before the post body starts).
- Usage: Ideal for adding banners, introductory content, or widgets before the actual content begins.
- Code Example : This snippet displays a customizable promotional banner across all public pages, promoting the XYZ WP Insert Code Snippet plugin,inserts this banner before the content on posts, pages, or custom post types.
Output :
4.2 Insert After Content(if allowed)
- The snippet is inserted after the main content of the page (after the post body ends).
- Usage: Perfect for displaying related posts, promo banners, or extra information after the content ends.
4.3 Insert Before Paragraph(if allowed)
- The snippet is inserted before a specific paragraph in the content.
- Usage: Useful for inserting small widgets, ads, or information before a particular paragraph, especially in long-form content.
4.4 Insert After Paragraph(if allowed)
- The snippet is inserted after a specific paragraph in the content.
- Usage: Ideal for placing ads or additional content that follows a specific section of the page, like between paragraphs of a post.
5. Categories, Archives, Tags, Taxonomies (List Views for Content)
These placements refer to category, archive, tag, or taxonomy pages, which list multiple posts or content ( if the theme allows ).
5.1 After Post(if allowed)
- The snippet is inserted after each post on category, archive, or tag pages.
- Usage: Ideal for inserting an ad, related posts section, or any content that should appear after each post in the listing.
Code Example for Insertion:
Code Output
5.2 Before Post(if allowed)
- The snippet is inserted before each post on category, archive, or tag pages.
- Usage: This placement is useful for adding a promo banner or message before the actual post content on listing pages.
5.3 Insert Before Excerpt(if allowed)
- The snippet is inserted before the excerpt of each post on category, archive, or tag pages.
- Usage: This is ideal for placing a promo banner, ad, or call-to-action before the short description or excerpt of the posts.
5.4 Insert After Excerpt(if allowed)
- The snippet is inserted immediately after the excerpt of each post.
- Usage: Use this for displaying additional information, banners, or ads after the post preview on listing pages.
5.5 Between Posts(if allowed)
- The snippet is inserted between individual posts on category, archive, or taxonomy pages.
- Usage: Perfect for adding a banner or content that should appear between each post in the list, such as a large promo banner between posts on a category page.