Title: posts is NULL
Last modified: May 17, 2018

---

# posts is NULL

 *  Resolved [amywieliczka](https://wordpress.org/support/users/amywieliczka/)
 * (@amywieliczka)
 * [8 years ago](https://wordpress.org/support/topic/posts-is-null/)
 * I’m using another plugin, User Access Manager. UAM adds a filter function to 
   the hook `the_posts`. This hook supplies a post list as a parameter, which is
   defined as an array: [https://developer.wordpress.org/reference/hooks/the_posts/](https://developer.wordpress.org/reference/hooks/the_posts/).
   Somehow, when this function is called while using the CloudSearch plugin, the
   post list is `NULL`.
 * When using the CloudSearch plugin, it looks like the `acs_plugin_disable_search_wp_query`
   function attached to the `posts_request` hook. The `acs_plugin_disable_search_wp_query`
   function returns `false`, but `the_posts` action is still triggered, even though`
   $posts` is `null` because no (sql) search has actually been performed.
 * Any ideas how to solve this problem?
 * One idea, in `cloud-search-hooks.php`:
 *     ```
       function acs_plugin_the_posts( $posts, $query ) {
           if ( is_null( $posts ) ) {
               $posts = array();
               return $posts;
           }
       }
       add_filter( 'the_posts', 'acs_plugin_the_posts', 9, 2);
       ```
   
 * The priority must be 9 in order to run _before_ the UAM hook. I’m not sure if
   this has undesired side effects elsewhere, and it seems like common best-practice
   is to define the priority of filters as 10. Also I’m very new to WordPress.
 * It seems like a better solution would be to disable default WordPress search 
   more fully – why is `the_posts` action hook getting triggered in the first place?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Andrea Landonio](https://wordpress.org/support/users/lando1982/)
 * (@lando1982)
 * [8 years ago](https://wordpress.org/support/topic/posts-is-null/#post-10295583)
 * Hi Amy,
 * I’m not sure I’ve understood well your problem.. You got NULL after “acs_plugin_disable_search_wp_query”
   and this create problems in other parts of your code/site?
    Please give me more
   details.. I think that we have many possible solutions. Bye
 *  Thread Starter [amywieliczka](https://wordpress.org/support/users/amywieliczka/)
 * (@amywieliczka)
 * [8 years ago](https://wordpress.org/support/topic/posts-is-null/#post-10305461)
 * Hi Andrea,
 * Yes, the CloudSearch plugin seems to disable WordPress sql search with the `acs_plugin_disable_search_wp_query`
   function by returning false. This seems to prevent WordPress from performing 
   a sql query, but it doesn’t seem to prevent WordPress from firing the other action
   hooks associated with search. So it causes a plugin conflict with another part
   of our code base.
 * One such hook that winds up getting fired, `the_posts`, has a function attached
   to it in another plugin: `attach_filter('the_posts', 'user_access_manager_plugin_function',
   10, 2)`, where `user_access_manager_plugin_fuction` has a function signature:`
   function user_access_manager_plugin_function( $posts, $query )`. The `user_access_manager_plugin_function`
   is expecting `$posts` to be an array, as specified here: [https://developer.wordpress.org/reference/hooks/the_posts/](https://developer.wordpress.org/reference/hooks/the_posts/).
 * This hook is provided so that plugins may filter a list of posts returned by 
   search. The plugin provides a function to filter the posts based on access restrictions.
   In our particular case, nothing is indexed to CloudSearch that has access restrictions,
   so I don’t particularly care to use this feature and I’m fine with _completely_
   bypassing typical WordPress search. However, returning false doesn’t entirely
   bypass WordPress search – the remaining search action hooks are still called,
   but $posts is NULL.
 * I tried to figure out a way to _entirely_ bypass WordPress search – including
   all the respective hooks – but couldn’t figure that out. The next solution to
   come to mind was attaching a filter within the CloudSearch plugin: `attach_filter('
   the posts', 'acs_plugin_the_posts', 9, 2)`, as described above.
    -  This reply was modified 8 years ago by [amywieliczka](https://wordpress.org/support/users/amywieliczka/).
    -  This reply was modified 8 years ago by [amywieliczka](https://wordpress.org/support/users/amywieliczka/).
 *  Plugin Author [Andrea Landonio](https://wordpress.org/support/users/lando1982/)
 * (@lando1982)
 * [8 years ago](https://wordpress.org/support/topic/posts-is-null/#post-10308198)
 * Hi Amy,
 * your idea to add a filter ‘acs_plugin_the_posts’ seems to work fine for me.. 
   I’m working on an update for the plugin, I’ll include your filter to the next
   release..
    I tell you when it’s ready Thanks for the suggestion!
 * Bye
 *  Plugin Author [Andrea Landonio](https://wordpress.org/support/users/lando1982/)
 * (@lando1982)
 * [8 years ago](https://wordpress.org/support/topic/posts-is-null/#post-10311862)
 * Hi Amy,
 * I’ve released a new version (1.8.0) of the plugin with your filter.. let me know
   if it work.. 😉
 *  Thread Starter [amywieliczka](https://wordpress.org/support/users/amywieliczka/)
 * (@amywieliczka)
 * [8 years ago](https://wordpress.org/support/topic/posts-is-null/#post-10320690)
 * Thanks Andrea!
 *  Plugin Author [Andrea Landonio](https://wordpress.org/support/users/lando1982/)
 * (@lando1982)
 * [8 years ago](https://wordpress.org/support/topic/posts-is-null/#post-10323284)
 * Thanks to you Amy!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘posts is NULL’ is closed to new replies.

 * ![](https://ps.w.org/cloud-search/assets/icon-256x256.png?rev=1350439)
 * [CloudSearch](https://wordpress.org/plugins/cloud-search/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cloud-search/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cloud-search/)
 * [Active Topics](https://wordpress.org/support/plugin/cloud-search/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cloud-search/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cloud-search/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Andrea Landonio](https://wordpress.org/support/users/lando1982/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/posts-is-null/#post-10323284)
 * Status: resolved