-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Once activated the plugin creates a custom post type, taxonomy, and shortcode all of which are called "includes."
-
[includes slug="post-slug"]
Displays post content from the Includes post type, and optionally all posts and pages -
[includes code slug="post-slug"]
Displays code content from the Includes post type -
[includes category="category-slug"]
Displays post content based on the category slug
The [includes]
shortcode requires either the slug
, or category
attributes for the shortcode to function property.
When the category
attribute is used two extra attributes can be applied: orderby
and order
.
Category attribute: orderby
none | No order
ID | Order by post id
date | Order by published date
title | Order by post title
slug | Order by post slug
rand | Randomize order
modified | Order by modified date
**Category attribute:** order
desc | Descending order ( default )
asc | Ascending Order
In the left WP Admin area menu select the "Includes" menu, then click the "Settings" link to open plugin settings.
- Enable shortcode viewer: Uses an empty template to view/test Includes
- Disable to use the your themes default page template view/test Includes
- Enable includes shortcode field(s) on Includes post type view
- Adds input fields to quick access the shortcode when viewing saved Includes
- Enable includes shortcode field(s) on category term pages
- Helpful if you use categories, does the same as above but on the Includes term pages
- Enable shortcode widget - a custom widget that renders shortcodes
- Add shortcode(s) to classic widgets. Renders shortcode content in block widgets
- Enable code editor and allow the Includes shortcode to render saved code
- Only enable if needed (allows CSS, PHP, JavaScript, etc)
- Allow "slugs" from posts and pages to be used by the Includes shortcode
- If used, test to ensure included content works as expected
- Allow post and page titles to render shortcodes
- Only enable if needed, requires extra resources
- Allow menus to render shortcodes
- Only enable if needed, requires extra resources
- Allow widgets to render shortcodes
- Only enable if needed, requires extra resources
The above 4 "other default disabled features" will consume more PHP memory, while minor it is still more. The more features that get enabled, the more memory that PHP will use. Some hosting providers, themes, and other plugins sometimes reach PHP memory limits when using these features. Use them sparingly.
The Includes plugin uses YahnisElsts/plugin-update-checker to allow updates to work like any other WordPress plugin - other than it updates from GitHub instead of the official WordPress repo.
Running npm run version
automatically populates the updates.json file. Plugin update checker reads this file to check if an update is pending.
When previewing an Include a custom empty template is used to display the content - this feature can be enabled and disabled within settings. The preview is only viewable to logged in administrators. The purpose of the blank template is to show off an example of saved Includes to ensure the content works as expected.
Advanced users can override the default template by creating the file template-parts/includes-preview.php
. Once defined the plugin will automatically use that template to preview saved Includes.
The preview template comes with two action hooks before and after content display.
- Before content hook:
do_action('includes_before_content');
- After content hook:
do_action('includes_after_content');
Example of opening a container, row, and column before the included content
/**
* Any Custom Content Before Includes Post Type Content
*/
function includes_before_content(): void {
$html = '<div class="container">';
$html .= '<div class="row">';
$html .= '<div class="col">';
return $html;
}
add_action( 'includes_before_content', 'includes_before_content' );
Example of closing a column, row and container after the included content
/**
* Any Custom Content After Includes Post Type Content
*/
function includes_after_content(): void {
$html = '</div><!-- .col -->';
$html = '</div><!-- .row -->';
$html .= '</div><!-- .container -->';
return $html;
}
add_action( 'includes_after_content', 'includes_after_content' );
Use an Include anytime you repeat blocks of duplicate content across different pages, widgets, menus or come up with your own specialized needs.
Includes within Includes works when stacking one level deep in direct line ( parent -> child or child -> parent ). In rare cases, stacking Includes can cause issues with some themes and may consume more memory than your host provides - stack only when needed!
A typical use case would be injecting html blocks into to a page to complete the document. For example, Includes for an opt-in form ( the child ), is included within a homepage Include ( the parent ). The parents Includes shortcode is then added to the actual published homepage post - and not another Include. This is a simple child -> parent stack.
Keeping the example in mind above, an incorrect usage example would be adding another child Include inside the opt-in form Include. Stacked together this would create child->child->parent, which the Plugin will not render.
The parent Include can include multiple child Includes, as long as the child Includes are not stacked within each other.
Includes within categories can be rotated using both the category and orderby attributes together.
Example: [includes category="category-slug" orderby="rand"]
• Create several Includes, containing content to be rotated and each assigned to the same category
- Set the title to something helpful: "Footer Widget Links - Group 1" or any format you would like to follow
- Under the Categories Metabox, click + Add New Category and create a custom category to group related items into. Group them based on the location they will be Included at, ie: Sidebar, Footer Right Widget, etc
This requires grouping related homepage Includes into the same category, scheduling the Includes for future release, and using the Includes category shortcode to display the newest homepage Include.
Step 1:
• Create Includes that will each contain the guts/body of the homepage content, creating unique variations for different promotions, holidays, visual changes, split tests, etc
- Set the title to something helpful: "Homepage - Date | Promo X" or any format you would like to follow
- Modify the post Permalink slug to something short and relevant: promo-x
- Under the Categories Metabox, click + Add New Category and create a custom homepage category to group related homepages into
- Build the page / add some content; temporary text will work for now or copy over your current homepage Page if you already have one
• Duplicate the above step( s ) for each new homepage variation. Use the WordPress.org hosted plugin to easily Duplicate Posts of any type
- Group related custom homepages into the same category
- Schedule future updates for page variations as you would any other post/page. You can also schedule the child Includes to update/change
Step 2:
• Edit your current homepage Page or create a new homepage Page that use the Includes category shortcode. Depending on how your homepage setup works, your homepage Page may have HTML ( like containers, etc ) within it or the Includes may contain all of the HTML
- Set the title to "Homepage" and the Permalink slug to lowercase version "homepage"
- Add the
[includes category="your-category-slug" orderby="date"]
to the page body - if you are using the Classic editor click the "Text" tab to paste the shortcode. If you're using the Gutenberg editor, click the + icon to Write your story, with the dialog box open select the Widgets panel, then click the Shortcode icon and enter the entire Includes category shortcode into the input box
Step 3:
• Set the websites Homepage to use the new Homepage Page.
- Open Settings > Reading
- Under the "Your homepage displays" section, select the "A static page" option, then in the Homepage dropdown select the "Homepage" Page template
- Click the Save Changes button
Step 4:
• Validate your Website
- Check that the homepage is using the Homepage Page template and displaying the Homepage Include
- Inspect the homepage for any unexpected issues; typical issues include wrong sidebar or non-full width template
- Test that the homepage updates by duplicating the current Include Homepage ( Promo X ). Make a minor change ( reword a link/button ), then schedule the modified Include to publish a minute later. Wait a minute, refresh the homepage, and validate the page changed
- If the page does not update, chances are a cache-plugin is not refreshing when new content is published
Step 1:
• Create multiple new Includes that each contain matching advertisement layouts/formats.
- Set the title to something helpful: "Sponsor Name - 125x125" or any format you would like to follow.
- Modify the post Permalink slug to something short and relevant: sponsor-name-125x125.
- Under the Categories Metabox, click + Add New Category and create a custom advertisement category to group related promotions into. Group them based on the location they will be Included at, ie: Sidebar, Footer Right Widget, etc. • Duplicate the above step( s ) for each new homepage variation. Use the WordPress.org hosted plugin to easily Duplicate Posts of any type.
- Remember to group related advertisements into the same category.
You are ready to split test if a page/website has enough unique visitors ( naturally via seo, ad buys, social campaigns, etc ) to create sustained sales ( leads, opt-ins, etc ) which are consistent enough to calculate both short and longterm conversion ratios.
Split tests should either target a single change that repeats ( like all call to action buttons at once ) or the entire page should change in some major way, like a different design, totally new copy, or some other major change.
For the best split test results the "change" should be above the fold of the page, within the first 560 pixels if possible or at least the first 710 pixels - or the change should repeat throughout the page like a sales call to action button. This is extremely important with lower traffic. For websites with long form copies, more traffic ( 10,000+ daily ) is required properly test such changes and typically more time, but that depends on the total traffic and sales.
For SEO driven tests, wait a few days to make sure the change does not fluctuate the listings, if you do get a traffic spike let the page settle for a few days/week( s ) before starting the test.
Step 1:
• Create 2+ Includes, each of which will contain a unique copy to split test
- Set the title to something helpful: "Promo X - Version 1" or any format you would like to follow
- If needed, modify the post Permalink slug to something short and relevant: promo-x-version-1
- Under the Categories Metabox, click + Add New Category and create a custom split test category or a unique category for this test • Duplicate the above step( s ) for each new homepage variation. Use the WordPress.org hosted plugin to easily Duplicate Posts of any type
- Remember to group related split tests into the same category
Using Includes to manage opt-in forms is incredibility helpful. Even simply pasting the opt-in HTML into an Include, and then adding the Include to a widget will allow you to use the full editor to manage the design/html, rather than a small widget.
However, grouping related opt-in forms into categories will allow you to rotate/update opt-in forms, even split test various form layouts, colors, or promotional messages. Which means means many different opt-in form styles, layouts, etc will need to be created to get the most out of this feature.
Most variations are simple enough to make, however at some point all of us start to run dry on ideas so below is a few ideas that you can use to help add a few extra forms to the rotation.
- Pre-holiday ( week before ) & and holiday ( week of ) design changes
- National holiday recognition, ie: national pizza day, bake a cake day, etc
- Major upcoming sales/promotions, like Black Friday or spring clearance sales
- Opt-in to get access/download, etc lead generators that are not full time promotions
- Forms in different locations ( ie footer vs. sidebar ) should be unique from each other; mix up the promotional hook, the look, design/color, make them unique. While forms within the same category or display location ( ie footer left widget ) might only slightly change; everything is the same other than the labels are inside the form inputs rather than above each input
- Anytime content is duplicated on posts, pages, other post types, etc. Common duplicate content includes custom Author Cards/Bio's and Real Estate Disclosure Statements.
- Create an Includes widget category and store all text/html widgets as Includes for easier backup & restore ability
- Centralize store policies that repeat on various product / store pages
- Centralize store F.A.Q .'s that repeat on various product / store pages
- Centralize advertisement management, reduce the need for JavaScript to rotate or load advertisements
- Centralized tracking codes used for everything; homepage rotations, promotions, opt-in form performance, etc