I think you have 2 options to set the pager offset programmatically:
Because views_embed_view()
does not take any parameters for a pager or exposed filters directly, I think you could implement your own version of its "guts" that also internally sets the pager data manually. Here's an excerpt of how to do that from this post (disclaimer, I've not personally tested this):
$view_args = array(); // contextual filter args go here
$view_object = views_get_view($view_name);
$view_object->set_current_page($offset); // manually set page offset
$html = $view_object->preview($view_display, $view_args);
Alternatively, if really have to use views_embed_view()
, then I think you'll have to modify the $_GET
global variable directly before-hand, or ensure that your "page" query string is already in the URL. As far as I know views typically extracts the pager offset directly from $_GET['page']
. The trick here is that it's not necessarily guaranteed that view's internal build/execute methods didn't manually overrride the pager data in some way, and you would have to be sure you don't have any conflicts with other pagers on the same page. It's also never great to be manipulating globals directly. Anyway, for most vanilla views, setting $_GET['page']
before calling views_embed_view()
would likely work, but the first solution is still probably preferred.