Help with hook_views_pre_build()
EDIT

You can try the below code its working fine for me.

$views-&gt;items_per_page($item_num); instead of 
$views-&gt;set_items_per_page($item_num);


Related questios

May be this can help you