Related
This Extension requires a Pro license
Current version: 1.5.4
Use SearchWP to power related content on your site!
SearchWP Related extension is designed to operate with minimal overhead while providing extensive customization options to match your site’s design and functionality requirements. Displaying related content to visitors is an effective strategy for maintaining engagement and encouraging users to explore additional pages on your site. If you’re currently using another related content system, SearchWP Related will likely reduce server overhead by utilizing the content index that SearchWP has already created.
Note: The SearchWP Related algorithm uses post entry titles as the default keyword source to identify and display related content across your site, ensuring relevant and contextually appropriate suggestions for your visitors.
Setup & Integration
Like all SearchWP Extensions, Related is a standalone WordPress plugin that runs alongside SearchWP. Once installed, the Related extension remains inactive by default until you configure it according to your preferences. You can access all configuration options and customize how related content appears on your post pages by navigating to SearchWP Settings → Related in your WordPress backend area.
Layout Themes
The layout theme section provides multiple pre-designed styles for displaying your related content block on the frontend of your website. You can easily switch between different layout themes and preview each option before saving your changes to ensure the design matches your site’s aesthetic.
Minimal: This theme presents a clean, simple list layout that displays only post titles arranged in an organized grid format.
Columns: This grid layout displays results across multiple columns, featuring both post titles and descriptions to provide visitors with more context about each related item.
Thumbnail: This layout combines a grid structure with large-sized featured images alongside post titles, creating a visually appealing display that emphasizes visual content.
Rich: This comprehensive layout option provides the most visually engaging presentation, featuring large images, post titles, and descriptions in an attractive grid format that maximizes visual appeal and information density.
Custom: This flexible option allows you to create a completely customized layout by combining and adjusting various settings from the related content configuration section to meet your specific design requirements.
Layout Style
The layout style setting allows you to choose between grid and list view formats for displaying your related content. Additionally, you can specify the exact number of related results to display within each related content block, giving you precise control over the amount of content presented to visitors.
Block Title
The block title setting determines the heading text that appears above your related content section on the frontend. The default value is “Related Content,” but you can edit it as per your site content.
Images
Choose the image size displayed with each related post. Available size options are small, medium, and large.
Descriptions:
A toggle to show or hide descriptions for related block content.
Engine
The engine setting defines which SearchWP engine will be used to determine the post types included in your related content suggestions. Only post sources that have been added to your selected engine settings will be eligible for display in the related content block.
Auto-Append Functionality
The auto-append feature allows you to select specific post types where the related content block will automatically appear on post pages without requiring manual placement. Only post types that have been added to your SearchWP engine will be available for selection in this setting.
You can also specify the precise position where related content should appear on your pages, with options to display the block at the bottom of your content or after a specific paragraph within your post content.
Exclude Entries
The exclude entries option provides granular control over which posts appear in your related content suggestions. You can exclude specific post IDs from appearing in any related content blocks across your site.
Alternatively, by selecting the “Search selected IDs only” option, you can restrict related content to a defined list of posts.
Embedding Your Block
Beyond the auto-append option, you can embed the Related Content block manually in various ways:
Gutenberg Block Integration
The Gutenberg block method provides seamless integration with WordPress’s modern block editor, allowing you to embed SearchWP related content directly into any post or page. While editing any post or page in the Gutenberg editor, simply search for the “Related” block and add it to your desired location.
Shortcode Implementation
You can utilize the [searchwp_related] shortcode to display related content within any shortcode-compatible area of your website.
Widget Integration
For themes that utilize sidebar areas with widget functionality, SearchWP Related provides a dedicated widget option that allows you to display related content within sidebar areas on your post pages.
PHP Code Integration
If you’re working with custom post templates or theme files, you can implement related content using direct PHP code integration. This method provides the most technical control and allows developers to place related content blocks precisely within custom theme template code and styling frameworks.
Post-Specific Configuration
When you select specific post types under the auto-append option, additional SearchWP Related extension settings become available under the “SearchWP Related Content” heading in the post editing screen for those post types.
Custom Keywords
By default, the related content algorithm analyzes keywords found in post titles to identify related content suggestions for each post. However, the custom keywords option allows you to specify alternative keywords for finding related content for specific posts.
This feature includes a “Results Sample” preview that displays which posts will appear in the related content block based on your custom keyword selections, allowing you to verify the relevance of suggested content before publishing.
Always Include Settings
The settings button located to the right of the custom keywords section, reveals additional configuration options, including the “Always Include” feature.
This powerful option allows you to manually select specific post titles that you want to guarantee will appear in the related content block for the current post, regardless of algorithmic matching. This ensures that important or strategically related content always appears in your related content suggestions, providing editorial control over automated recommendations.
Customizing output: the template loader
As is the case with Live Search, Related also uses a template loader to allow for full customization of Related results. There is a default template that looks something like this:
In the Related plugin folder there is another folder named templates containing this default Related template (related.php
) used to display Related content.
~/wp-content/plugins/searchwp-related/templates/related.php
The contents of this file are as follows: related.php
Do not edit this file directly. If you install an update to Related, any customizations you make to this file will be overwritten!
Instead, you can utilize the template loader built into Related to add your own custom template within your theme.
To customize the output of Related content, create a new folder within your theme and paste a copy of the default Related template into that folder, keeping the same filename:
~/wp-content/themes/my-theme/searchwp-related/related.php
You can fully customize this template to meet your needs. It’s based on The Loop, and you can do anything within the template you would in any other theme template.
Template Options
While the template used to show Related content is mostly a standard theme template, you can influence how Related behaves by editing the optional comment block at the top of the file:
/** * SearchWP Engine: default * Maximum Results: 3 */<code></code>
You can customize the SearchWP engine used, and the maximum number of Related entries displayed by editing the applicable line at the top of the template.
You can also customize results templates per post type by appending a hyphen and the post type to the file name. For example, if you were to create a template with this filename:
~/wp-content/themes/my-theme/searchwp-related/related-page.php
It would be used only for Pages. All other post types would use the base template.
Programmatically retrieve Related content
If you want to use the template loader but in a different spot than the auto-append checkbox uses, leave that checkbox unticked and edit your template file to include the following where you want Related output:
You can also skip the template loader entirely and instead retrieve Related content directly in your theme code. Here’s how you can do that:
There are a number of arguments you can pass to customize how Related will find related content, here’s a full breakdown of the possible arguments:
It’s suggested that you set up some sort of caching (e.g. via Transient) to reduce resource usage.
Customizing input: defining Related content
Related by default will build a keyword list from the title of your entries. Common words are removed so as to increase relevancy of Related results. On every entry edit screen, Related will output a meta box allowing you to customize what keyword(s) are used to determine Related content:
A set of three sample results are displayed, allowing you to customize the keyword(s) you’re using if you’d like. This is just a sample, the template loader controls how the results are displayed on the front end, and SearchWP determines which entries to display at runtime.
The Results samples will include all the available engines. If you want to limit the samples displayed to only some engines you can use this filter:
Changelog
1.5.4
- [Fix] Draft, pending posts listed on Always Include option and potentially displayed on frontend.
- [Update] Updated updater.
1.5.3
- [New] Added
searchwp_related_meta_box_sample_engines
hook to filter the engines displayed in the metabox samples. - [Change] Sample results are now responsive.
1.5.2
- [Fix] JavaScript error if SearchWP "Hide Announcement" option is enabled.
1.5.1
- [Change] Added "Tested up to" tag to indicate the latest WP version compatibility
- [Change] Removed build files to avoid triggering automations on some systems
- [Fix] PHP error when SearchWP plugin is not active
1.5.0
- [New] The settings area is revamped providing more control over the content and visual appearance of the Related block
- [New] New Gutenberg block and Shortcode are added for manual embedding
- [Change] Minimal required SearchWP version for the Related extension is 4.2.6
- [Change] Removed redundant/unused functions and methods
1.4.8
- [Fix] Error in PHP versions prior to 7.3 caused by a function call trailing comma
- [Fix] List of suggestions is not re-rendered on Keywords field change in the post metabox
- [Fix] Deprecation notices on PHP 8.2
1.4.7
- [Fix] Parse error for PHP 7.2 and lower
- [Fix] Compatibility with SearchWP 4.2.0 and above
1.4.6
- [New] Context array added to
searchwp_related_default_keywords
- [Fix] PHP Notice
- [Fix] Excluded posts in preview in some cases
1.4.5
- [Fix] Initial preview render
1.4.4
- [Fix] PHP Notice, Error in some cases
- [Update] Updated updater
1.4.3
- [Fix] Prevent logging in SearchWP Metrics when applicable
1.4.2
- [Fix] Fixes Error when using SearchWP 4
1.4.0
- [New] Adds support for SearchWP 4
1.3
- [New] Force specific Related entries for each entry
- [New] Related content is now cached for 12 hours
- [New] Hook to control query cache TTL in seconds
searchwp_related_cache_length
- [New] Hook to control whether caching is used
searchwp_related_cache_enabled
- [Fix] Auto-append not working in some cases
- [Fix] Pagination not respected in some cases
- [Fix] Default keywords not populated in some cases
- [Fix] Links to documentation
- [Change] Meta box no longer appears on non-public post types by default
- [Change] Additional results found if initial results set is too restricted by SearchWP
- [Update] Translation source
- [Update] Updated updater
1.1.1
- [Change] Fallback keyword set is now defined when Drafts are saved (was previously on Publish)
1.1
- [New] Adds Widget
- [New] New hooks to control meta box placement
searchwp_related_meta_box_context
andsearchwp_related_meta_box_priority
1.0.4
- [Fix] Fixed an issue with overzealous enqueues
1.0.3
- [Fix] Fixed an issue where Related entries were not found in certain circumstances
- [Update] Updated updater
1.0.2
- [Fix] Newly published entries are no longer automatically skipped if no keywords are entered, will use fallbacks by default
- [Fix] Implementation of
searchwp_related_excluded_post_types
filter is now applied correctly and works
1.0.1
- [Fix] Prevent PHP(<5.5) Fatal error
Can't use function return value in write context
1.0.0
- Initial release