Skip to content
Chris Winters edited this page Mar 5, 2023 · 25 revisions

Includes Wiki

Once activated the plugin creates a custom post type, taxonomy, and shortcode all of which are called "includes."

Shortcodes

  • [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

Attributes

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

Plugin settings

In the left WP Admin area menu select the "Includes" menu, then click the "Settings" link to open plugin settings.

Default enabled user interface features

  • 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

Default disabled user interface features

  • 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)

Other default disabled features

  • 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

PHP memory limits

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.

Includes within Includes

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.

Clone this wiki locally