A new Pro Extension has been released: Related. You can now use SearchWP to power a related content system on your site!
SearchWP knows a lot about the content on your site. Showing visitors related content can help extend their stay by exposing entries related to the one currently on display. If you’re currently using another related content solution, this extension can also lighten the load on your server by reducing the overhead of maintaining a separate related content index, or running heavy database queries at runtime.
Like SearchWP itself and its other extensions, Related was built with developers in mind. It’s as much a customizable system as it is a turnkey solution.
By default Related doesn’t do anything, but you can opt in to having Related automatically append related entries (per post type) on its settings screen (accessed via the Extensions dropdown on the SearchWP settings screen):
Once that’s in place, Related will show up to 3 related entries to the current entry:
Related ships with an auto append default template designed to fit in well with your theme, but that’s not enough. There is a full template loader built in, allowing you to easily completely customize the look and feel of your related content.
The template loader is great because it allows you to completely specify the markup and style used for your Related content without having to muck with hooks or dequeueing assets or behavior that’s getting in your way.
If auto appending isn’t your style, you can programmatically utilize Related to find related content, and do what you want with it! It’s as easy as:
|* Programmatically find Related content from SearchWP Related|
|$args = array(|
|'s' => 'coffee', // keywords (space separated) to use when finding Related content|
|'engine' => 'default', // the SearchWP engine to use|
|'posts_per_page' => 3, // how many entries to find|
|// Instantiate SearchWP Related|
|$searchwp_related = new SearchWP_Related();|
|// Retrieve Related content for the current post|
|$related_content = $searchwp_related->get( $args );|
|// Returns an array of Post objects for you to loop through|
|print_r( $related_content );|
The last bit of detail that comes to working with related content is specifying how that related content is found. SearchWP is a powerful, keyword based search index for your WordPress site. A keyword-based system for finding related content makes perfect sense. When editing entries on your site, you can easily define what keywords are used to find Related content:
By default, Related will build a fallback set of keywords to use based on the title of your entries. This saves you some time when first activating Related, so you don’t have to edit every single entry on your site to determine a keyword set to use. Keywords can be updated at any time.
Related is a powerful related content solution, making use of SearchWP’s optimized index to find related content in real time without over-utilizing your server. Enjoy!