WordPress VIP-compatible plugin for the Sophi.io Site Automation service.
Sophi.io is a suite of artificial intelligence (AI) tools developed by The Globe and Mail to help content publishers make important strategic and tactical decisions. The tools range from automated content curation engines to predictive analytics and paywall solutions.
Sophi-driven pages outperform human curated pages by a significant margin and free up publisher resources so that they can focus on finding the next story that matters. Invisible, automated curation of your home and section pages to streamline your team’s workflow. Continuously optimize the performance characteristics of the site based on demand and your brand, so the content is always the right fit.
Note that if you are on the WordPress VIP platform that you will not be able to upload a plugin in the WordPress Admin so you will need to follow steps in 1b.
You can upload and install the plugin ZIP file via the WordPress dashboard (Plugins
> Add New
-> Upload Plugin
) or manually inside of the wp-content/plugins
directory, and activate on the Plugins dashboard.
git clone https://github.com/globeandmail/sophi-for-wordpress.git && cd sophi-for-wordpress
composer install && npm install && npm run build
Click the Activate
link after installing the plugin.
Go to Settings
> Sophi
in the WordPress Admin and enter your Sophi Collector and Site Automation credentials supplied by the Sophi.io team. Click Save Changes
button to validate and save your credentials.
Once your credentials are validated and saved, your site is officially supercharged by the Sophi.io Site Automation service. You also have access to Sophi for WordPress' powerful WP_Query parameters and custom Sophi Site Automation block, which enables you to utilize Site Automation to power the content curation on your site.
There are two potential ways to integrate Sophi Site Automation results with your WordPress site. The default approach includes a Sophi Site Automation block that integrates with get_posts
by injecting Posts IDs via the posts_pre_query
filter that gets fetched later to return the actual Posts. In the same fashion, you can integrate Sophi results with your WP_Query
object by setting the sophi_curated_page
and sophi_curated_widget
query parameters.
More details on each of these two options are described below. If you are not certain on the best integration approach, considering the following:
Reasons to use the Site Automation block:
Reasons to use the Query integration:
You can utilize the Site Automation block by configuring the Site Automation page and widget names and adjusting block content and post meta settings to display Site Automation content on your site.
The Site Automation block comes with a barebone HTML output and styling. It's made to be filtered using sophi_site_automation_block_output
.
add_filter(
'sophi_site_automation_block_output',
function( $output, $curated_posts, $attributes, $content, $block ) {
// ...
return $new_output;
},
10,
5
);
The Site Automation block will automatically add a data-sophi-feature=<widget_name>
attribute for the rendered HTML content so Sophi can understand what content section is rendered on your site.
The Site Automation block uses query integration under the hood. You can query for Sophi curated articles by passing sophi_curated_page
and sophi_curated_widget
to your WP_Query queries.
$the_query = new WP_Query( [
'sophi_curated_page' => 'page-name',
'sophi_curated_widget' => 'widget-name',
] );
Note that you need to add data-sophi-feature=<widget_name>
to the wrapper div of your post for Sophi to capture your widget better.
<div class="posts-wrapper" data-sophi-feature="trending">
<!-- Post lists -->
</div>
WP_Query
While the above query integration works just fine, it has been observed on WordPress VIP infrastructure that WP_Query
may return latest posts instead of the posts curated by Sophi due to the Advanced Post Cache plugin used by the VIP platform. A workaround for this is to use get_posts()
instead and as good practice to add a comment explaining the usage of it so that developers new to it don't swap it for WP_Query
. Also remember to whitelist get_posts
by adding the following inline comment so that PHPCS doesn't throw a warning:
phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts
Sophi for WordPress has an in-depth documentation site that details the available actions and filters found within the plugin, as well as some helpful tutorials on how to use those hooks. Visit the developer docs ☞
If you are having difficulties with your Sophi integration, then we recommend utilizing the Debug Bar for Sophi plugin to help triage your Sophi Authentication, Sophi API integration, and CMS publish/update events.
The award-winning Sophi suite of solutions was developed by The Globe and Mail to help content publishers make important strategic and tactical decisions that transform their business. It is a suite of ML and NLP-powered tools that includes Sophi Automation for content curation, Sophi for Paywalls, and Sophi Analytics – a decision-support system for publishers.
The Globe and Mail saw a dramatic improvement in the business metrics that matter:
You can read more details in The Globe and Mail case study.
The same Privacy & Terms that govern The Globe and Mail cover the Sophi.io service.
Active: The Globe and Mail is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.
A complete listing of all notable changes to Sophi for WordPress are documented in CHANGELOG.md.
Please read CODE_OF_CONDUCT.md for details on our code of conduct, CONTRIBUTING.md for details on the process for submitting pull requests to us, and CREDITS.md for a listing of maintainers, contributors, and libraries for Sophi for WordPress.