2 added 255 characters in body
source | link

You can try the hook_views_pre_execute

function mycustommodule_views_pre_execute(\Drupal\views\ViewExecutable $view) {
  if ($view->id() == "mycustomview") {
    $query = $view->query;
    $query->setLimit(7);
    $query->setOffset(5);
  }
}

I think your problem is a filter not limit (If I understood correctly). If you want to add filter like 'WHERE' in sql follow this page : https://api.drupal.org/api/drupal/core!modules!views!views.api.php/function/hook_views_query_alter/8.2.x

You can try the hook_views_pre_execute

function mycustommodule_views_pre_execute(\Drupal\views\ViewExecutable $view) {
  if ($view->id() == "mycustomview") {
    $query = $view->query;
    $query->setLimit(7);
    $query->setOffset(5);
  }
}

You can try the hook_views_pre_execute

function mycustommodule_views_pre_execute(\Drupal\views\ViewExecutable $view) {
  if ($view->id() == "mycustomview") {
    $query = $view->query;
    $query->setLimit(7);
    $query->setOffset(5);
  }
}

I think your problem is a filter not limit (If I understood correctly). If you want to add filter like 'WHERE' in sql follow this page : https://api.drupal.org/api/drupal/core!modules!views!views.api.php/function/hook_views_query_alter/8.2.x

1
source | link

You can try the hook_views_pre_execute

function mycustommodule_views_pre_execute(\Drupal\views\ViewExecutable $view) {
  if ($view->id() == "mycustomview") {
    $query = $view->query;
    $query->setLimit(7);
    $query->setOffset(5);
  }
}