-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIT-2911: document default response for Sophi empty post array #307
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,8 @@ Note that you need to add `data-sophi-feature=<widget_name>` to the wrapper div | |
|
||
#### Caveats | ||
|
||
##### WordPress VIP and `WP_Query` | ||
|
||
While the above query integration works just fine, it has been observed on [WordPress VIP](https://wpvip.com/) infrastructure that `WP_Query` may return latest posts instead of the posts curated by Sophi due to the [Advanced Post Cache](https://github.com/Automattic/advanced-post-cache) plugin used by the VIP platform. A workaround for this is to use [`get_posts()`](https://developer.wordpress.org/reference/functions/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` | ||
|
@@ -163,6 +165,10 @@ Object caching is encouraged, as the plugin saves Sophi data as a transient. If | |
|
||
The default caching period is five minutes. This can be modified with the `sophi_cache_duration` hook. | ||
|
||
### Sophi API empty response | ||
|
||
If the Sophi API returns an empty Post ID array, the plugin will result in a "no results" response. The `found_posts` filter can be used to modify the Sophi API response to allow manual posts to be injected into the response (e.g., via a fallback method to inject posts that would be a good fit). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be the same filter |
||
|
||
## Documentation | ||
|
||
Sophi for WordPress has an in-depth documentation site that details the available actions and filters found within the plugin. [Visit the developer docs ☞](https://globeandmail.github.io/sophi-for-wordpress/) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jeffpaul the filter is actuallly
sophi_curated_post_list
https://github.com/globeandmail/sophi-for-wordpress/blob/9f768bf5341cacf97ccf9ba5813ed61138b88246/includes/classes/SiteAutomation/Integration.php#L113A dev would not really be injecting posts into the Sophi response, but rather inject them previous to returning the filtered value from
posts_pre_query
https://github.com/globeandmail/sophi-for-wordpress/blob/9f768bf5341cacf97ccf9ba5813ed61138b88246/includes/classes/SiteAutomation/Integration.php#L31