Title: Warning: array_slice Version 1.4.0
Last modified: November 20, 2016

---

# Warning: array_slice Version 1.4.0

 *  Resolved [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * (@johnnadeau)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/)
 * Hi Jeremy,
 * We have two sites, both running version 1.3.3 successfully since that version’s
   release (LakePath.com and LeLacAppelle.com)
 * We updated to version 1.4.0 on both sites today (Sunday 11/20/16) and it resulted
   in the error below.
 * I tried clearing our Cache (SiteGround SuperCacher at both web sites) & WebBrowser
   Cache to no avail.
 * I then rolled back LakePath to ver 1.3.3 (didn’t even flush the SiteGround cache),
   and all was well again at LakePath. For consistency, I then rolled back LeLacAppelle
   to ver 1.3.3.
 * Here’s a screenshot of how it works on LakePath with ver 1.3.3: [https://snag.gy/1l0zMc.jpg](https://snag.gy/1l0zMc.jpg)
 * **ISSUE**: On LakePath, in place of the LEFT COLUMN, where the Posts/Images are
   brought in from LeLacAppelle, here’s the error (repeated for each/every imported
   post):
    Warning: array_slice() expects parameter 1 to be array, object given 
   in /home/nadeauap/public_html/lakepath/wp-content/plugins/rest-api-post-embeds/
   rest-api-post-embeds.php on line 326
 * Please let me know if you need me to update the plugin to 1.4.0 and/or make any
   other changes to assist in troubleshooting this issue. Otherwise, I’ll remain
   at ver 1.3.3 until you advise.
 * Thanks in advance for all of your help and insight !
 * John

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/page/2/?output_format=md)

 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [9 years, 6 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8463800)
 * Could you check that you’re running one of the following on the site you’re pulling
   posts from?
    - WordPress 4.7 Beta
    - [the most recent version of REST API plugin](https://wordpress.org/plugins/rest-api/)
 * Let me know if it helps.
 *  Thread Starter [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * (@johnnadeau)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8465300)
 * Hi Jeremy,
 * No, we’re not running WordPress 4.7 Beta on either site.
 * Both sites are running WordPress 4.6.1.
 * Both sites are running WP REST API Version 2.0-beta15
 * All other plugins are up-to-date (including JetPack).
 * Let me know if you have any other questions.
 * Thanks,
 * John
 *  Thread Starter [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * (@johnnadeau)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8465328)
 * …edit…
 * I see that JetPack just presented a new version 4.4.
 * As of yesterday, we were running JetPack Version 4.3.2 on both sites.
 * We’ll continue to run the prior JetPack Version 4.3.2 unless you advise otherwise_(
   we normally like to wait 4-5 days before updating any plugin)_
 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [9 years, 6 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8465357)
 * Since you’re querying the WP REST API, the version of Jetpack won’t matter here.
 * Could you copy the shortcode you’re using, and paste it here so I can run some
   more tests?
 * Thanks!
 *  Thread Starter [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * (@johnnadeau)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8465447)
 * Hi Jeremy,
 * I have it in a Text Widget:
    [jeherve_post_embed url=”lelacappelle.com” wpapi
   =true include_images=”true” order_by=”rand” number=”5″ image_size=”202,114″ include_credits
   =”false” include_excerpt=”false” category=”Lake Moments”]
 * Thanks,
 * John
 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [9 years, 6 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8470324)
 * Thanks! I seem to see 2 issues here:
    1. Could you try to update that shortcode and use `"` instead of `”`, like so:
    2. `[jeherve_post_embed url="lelacappelle.com" wpapi=true include_images="true"
       order_by="rand" number="5" image_size="202,114" include_credits="false" include_excerpt
       ="false" category="Lake Moments"]`
    3. `rand` might not be supported by the WP REST API anymore. I receive the following
       error when trying to use that parameter: `orderby is not one of date, relevance,
       id, include, title, slug`
 * I’ll update my plugin’s documentation to reflect the changes. I’m afraid you’ll
   need to stop using using `order_by="rand"` as a shortcode parameter, at least
   until the parameter is added back to the WP REST API, if it is added back.
 *  Thread Starter [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * (@johnnadeau)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8473564)
 * Hi Jeremy,
 * **As to #1**: My apologies… when I pasted the code into the prior reply, it converted
   quotes into smartquotes 🙁 _(I should have inserted it as raw code as you did
   above)_. Bottom line, my code is exactly as you posted above.
 * **As to #2**: I had updated WP Rest API within a few days of its release to Version
   2.0-beta15. Displaying posts from LeLac inside of LakePath has been working ever
   since, until upgrading Rest API Post Embeds from 1.3.3 to version 1.4.0: I had
   not received any error regarding the `order_by="rand"`
 * **Now #3** as it may also relate to the original error?:
    You had me add the 
   code below into my Child/Functions.php to cause the posts to refresh after 1 
   minute, instead of 10. It has been working correctly using WP Rest API v2.0-beta15
   and Rest API Post Embeds v1.3.3
 *     ```
       /* JRN Note Changes default cache of 10 minutes to refresh posts */
       function jeherve_custom_api_embeds_caching() {
       	return 1 * MINUTE_IN_SECONDS;
       }
       add_filter( 'jeherve_post_embed_posts_cache', 'jeherve_custom_api_embeds_caching' );
       ```
   
 * **Wrapping up…**
    Do you see any issues if we stay on WP Rest API v2.0-beta15
   and Rest API Post Embeds v1.3.3? I really like your plugin and this functionality
   🙂
 * Thanks for your help!
 * John
 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [9 years, 6 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8473681)
 * > until upgrading Rest API Post Embeds from 1.3.3 to version 1.4.0: I had not
   > received any error regarding the `order_by="rand"`
 * That’s because my plugin hadn’t switched to using the updated API endpoints introduced
   in the WP REST API plugin, and that will be part of WordPress itself in a few
   weeks, when WordPress 4.7 is released.
 * You could continue to use Rest API Post Embeds v1.3.3 for a bit longer, but on
   the long term you will run into issues when you’ll want to stop using the WP 
   REST API plugin, and rely on WordPress itself to create the endpoints.
 * WordPress itself might change in the future, and start supporting random ordering
   again. The different ordering parameters will be audited, and may be customized,
   here:
    [https://core.trac.wordpress.org/ticket/38693](https://core.trac.wordpress.org/ticket/38693)
 * I’m sorry that’s not much of an answer, but the changes are still fresh (they
   were made [only a few weeks ago](https://core.trac.wordpress.org/ticket/38378#comment:8)),
   and I can’t seem to find a great way to add filters back just yet. It seems to
   be [in the works though](https://github.com/WP-API/WP-API/pull/2380), so you 
   might be able to add random sorting support back to the API on your site soon.
 * I’ll mention it in the plugin readme if that ever changes!
 *  Thread Starter [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * (@johnnadeau)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8625892)
 * Hi Jeremy,
 * I’ve been following the ticket you referenced. I’m a bit unclear as to how to
   proceed. Can you review the info below, then recommend a course of action?
    For
   example: –Upgrade to 4.7… or wait for 4.7.1… or wait for 4.8 ? –Drop or Keep 
   WP REST API plugin –Stay on v1.3.3 REST API Post Embeds or Upgrade to 1.4.0
 * Our last post in this thread was on 11/23/16 (above).
 * The last post in the ticket you referenced was on 12/1/16:
    [https://core.trac.wordpress.org/ticket/38693](https://core.trac.wordpress.org/ticket/38693).
 * Here’s where things stand on [LakePath.com](http://LakePath.com):
    –WordPress
   v4.6.1 –WP REST API v2.0-beta15 –REST API Post Embeds v1.3.3 –(all other plugins
   updated/current) –I’m using a Text Widget in Left Column: `[jeherve_post_embed
   url=”lelacappelle.com” wpapi=true include_images=”true” order_by=”rand” number
   =”5″ image_size=”202,114″ include_credits=”false” include_excerpt=”false” category
   =”Lake Moments”]` –I’m using the following filter in my child theme functions.
   php:
 *     ```
       function jeherve_custom_api_embeds_caching() {
       	return 1 * MINUTE_IN_SECONDS;
       }
       add_filter( 'jeherve_post_embed_posts_cache', 'jeherve_custom_api_embeds_caching' );
       ```
   
 * As always, I appreciate any help you might provide.
 * Thanks!
 * John
 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [9 years, 4 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8637553)
 * Could you try to add the snippet suggested [here](https://core.trac.wordpress.org/ticket/38693#comment:5)
   in your child theme’s functions.php file?
 * If it works, I’ll add it to my plugin so we don’t have to wait for a WordPress
   release for the problem to be fixed.
 * Thanks for giving it a try!
 *  Thread Starter [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * (@johnnadeau)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8637737)
 * Hi Jeremy,
 * OK… to be clear, I did _not_ update WordPress or your plugin yet.
 * I added the following to my child’s function.php:
 *     ```
       add_filter( 'rest_post_collection_params', 'my_prefix_add_rest_orderby_params', 10, 1 );
   
       function my_prefix_add_rest_orderby_params( $params ) {
           $params['orderby']['enum'][] = 'rand';
   
           return $params;
       }
       ```
   
 * It appears to be working, with the _**exception**_ of refreshing the posts that
   are displayed. As noted in my prior post, I have a code snippet that overrides
   the 10 minute refresh to 1 minute. I also tested after 10 minutes, then 20 minutes,
   but the posts remain the same as they were first displayed.
 * Here are the posts that were displayed at 7:32am, and remained the same as of
   8:02am _(after refreshing the page, or browsing to another page)_. [Posts Displayed](https://snag.gy/J5bkn6.jpg)
 * Seems like this behavior began after updating WP REST API to v2.0-beta15. Or 
   could it be the SiteGround cache _(on either LakePath.com or LeLacAppelle.com)_?
 * I will leave the new snippet in place and will not update WordPress or your plugin
   until you advise further.
 * Thanks!
 * John
 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [9 years, 4 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8638044)
 * Sorry, I should have been more clear. Let me clarify:
    - This snippet has to be added to the site you’re pulling posts from (lelacappelle.
      com).
    - lelacappelle.com has to be running WordPress 4.7.
    - LakePath.com should run the latest version of my plugin.
 * Once you’ve done that, wait until the data refreshes and you should be all set.
 *  Thread Starter [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * (@johnnadeau)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8738596)
 * Hi Jeremy,
 * Sorry for my absence 🙂
 * I was finally able to update both sites to 4.7.2, all plugins, including your’s,
   and make the code snippets changes on both sites as well.
 * Result: it **_does_** pull the posts in randomly, but it does _**not**_ appear
   to refresh them… even after 30 minutes.
 * These are the code snippets I currently have in Child Functions.php on both sites.
   Do you have any thoughts/suggestions?:
 *     ```
       /* JRN Note Changes default cache of 10 minutes to refresh posts */
       function jeherve_custom_api_embeds_caching() {
       	return 1 * MINUTE_IN_SECONDS;
       }
       add_filter( 'jeherve_post_embed_posts_cache', 'jeherve_custom_api_embeds_caching' );
   
       /* JRN Note Jeremy had me add to fix rand sort */
   
       add_filter( 'rest_post_collection_params', 'my_prefix_add_rest_orderby_params', 10, 1 );
   
       function my_prefix_add_rest_orderby_params( $params ) {
           $params['orderby']['enum'][] = 'rand';
   
           return $params;
       }
       ```
   
 *  Plugin Author [Jeremy Herve](https://wordpress.org/support/users/jeherve/)
 * (@jeherve)
 * Jetpack Mechanic 🚀
 * [9 years, 3 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8743219)
 * I wonder if that API request may be cached on your site. Do you use a caching
   plugin on lelacappelle.com?
 *  Thread Starter [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * (@johnnadeau)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/#post-8743700)
 * Hi Jeremy,
 * Yes, I think you identified the issue!
 * We use SG SuperCache v2.3.2 on both sites.
 * **I A/B tested it:**
    Loaded LakePath.com page in browser Waited 5 minutes Shift/
   Refreshed Webage in browser **A=**No change in displayed posts. Purged the SG
   SuperCache at LeLacAppelle.com Shift/Refreshed Webage in browser **B=**New set
   of posts were displayed.
 * _Note: SG SuperCache was renamed to SG Optimizer v3.05. As of last night, they
   were having problems with it causing high CPU usage, so I rolled back and did
   testing above under v.2.3.2._
 * Are there any changes I can make in the code snippet we’re using to force it 
   to bypass the cache, or should I reach out to SiteGround?
 * Thanks,
 * John

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/page/2/?output_format=md)

The topic ‘Warning: array_slice Version 1.4.0’ is closed to new replies.

 * ![](https://ps.w.org/rest-api-post-embeds/assets/icon.svg?rev=2495828)
 * [REST API Post Embeds](https://wordpress.org/plugins/rest-api-post-embeds/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/rest-api-post-embeds/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/rest-api-post-embeds/)
 * [Active Topics](https://wordpress.org/support/plugin/rest-api-post-embeds/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/rest-api-post-embeds/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/rest-api-post-embeds/reviews/)

 * 18 replies
 * 3 participants
 * Last reply from: [JohnNadeau](https://wordpress.org/support/users/johnnadeau/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/warning-array_slice-version-1-4-0/page/2/#post-8748300)
 * Status: resolved