How do I select a page using views_embed_view? I am writing a rather intensive ajax interface that requires me to manhandle views quite a bit. I am retrieving the results of the ajax triggers using

views_embed_view($view, $display, $arg1, $arg2);


Everything works great except the default pager ajax drops the custom info I'm dumping into views_embed_view

How can I use views_embed_view to select which pager page to return?

drupal 7, views 3
I found the answer after a good deal of research and testing. 

views_embed_view() does not have a way to do this. However, we can use the same method that views_embed_view() used.

1  $view_args = array($terms); //, $search_text
2  $view_object = views_get_view($view_name);
3  $view_object-&gt;set_current_page($offset);
4  $html = $view_object-&gt;preview($view_display, $view_args);


Line 1,2, and 3 are a simplified version of views_embed_view(). I'm bypassing permissions here so check out the function code to see how to do that part.

Line 3 is the part that sets the pager offset and solves my problem.

Note: their are two functions for setting the page offset and I used the wrong one the first time and it caused a log of confusion. The first function view-&gt;set_offset does not seem to work. I think it sets the correct value in the view object but without doing the theme and query work. so view-&gt;set_current_page is the one you want to use. I think it goes through the pager plugin to set the query and theme implications as well as set the offset.