I'm displaying a view on a pager with a mini pager. It has total number 15 pages.

I want to display page number 5 by default. The the next link will point to page number 6 and the previous link will point to page number 4.

I have tried the below code.

function mymodule_views_pre_execute(&$view) {
  $view->query->pager->current_page = 5;

It just moves the page number in the page number, displaying it as page 5 of 15 but the views displaying the results of the page 1.

It it possible to set the default page number of a pager? How? I'm using ajax in views.

1 Answer 1


I have found the answer. I'm sharing here the solution.

I used the following code and it worked.

function mymodule_views_pre_build(&$view) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.