How do I change total number of rows in a view programmatically? I had to remove manually some rows from a View programmatically for a lot of good reasons, too long to explain. I did it removing item in the pre-render hook from the array 

view -&gt; result


It works fine, but the total number of items contained in the view is not changed. How can i change it programmatically? I tried changing 

view -&gt; total_rows 


but it seems not to be enough. I saw a lot of total_items elements in the object view, and i think changing them would work, but there are 60 items like that, each contained in objects contained in arrays that are contained in objects and so on and i am not really sure how to change every element with that name, parsing the structure of the object view and changing every total_item with the number X instead of the number Y.
You're probably looking for the view::set_items_per_page() method, e.g.

/**
 * Implements hook_views_pre_build 
 **/
function MYMODULE_views_pre_build(&amp;$view) {
  if ($view-&gt;name == 'foo') {
    $view-&gt;set_items_per_page(10);
  }
}


That method updates both the instance var and the limit on the internal query that Views will eventually run.

Note that you need to make this change before the query is executed (i.e. in a pre build, not pre render, hook), or you'll get inconsistencies with pagers etc.