diff --git a/scheduler.module b/scheduler.module
index e30cc03..5d7e17a 100644
--- a/scheduler.module
+++ b/scheduler.module
@@ -500,3 +500,17 @@ function scheduler_feeds_set_target($source, $entity, $target, $value, $mapping)
     $entity->$target = $timestamp;
   }
 }
+
+/**
+ * Returns all content types for which scheduler has been enabled.
+ *
+ * @return \Drupal\node\NodeTypeInterface[]
+ */
+function scheduler_get_scheduler_enabled_node_types() {
+  $node_types = \Drupal\node\Entity\NodeType::loadMultiple();
+  return array_filter($node_types, function($bundle) {
+    /* @var \Drupal\node\NodeTypeInterface $bundle */
+    return $bundle->getThirdPartySetting('scheduler', 'publish_enable', FALSE)
+      || $bundle->getThirdPartySetting('scheduler', 'unpublish_enable', FALSE);
+  });
+}
\ No newline at end of file
diff --git a/src/SchedulerManager.php b/src/SchedulerManager.php
index eb58b53..246da9a 100644
--- a/src/SchedulerManager.php
+++ b/src/SchedulerManager.php
@@ -85,12 +85,17 @@ class SchedulerManager {
     $result = FALSE;
 
     // If the time now is greater than the time to publish a node, publish it.
-    $query = \Drupal::entityQuery('node')
-      ->condition('publish_on', 0, '>')
-      ->condition('publish_on', REQUEST_TIME, '<=');
-    // @todo Change this query to exclude nodes which are not enabled for
-    // publishing. See https://www.drupal.org/node/2659824
-    $nids = $query->execute();
+    $nids = [];
+    $scheduler_enabled_types = array_keys(scheduler_get_scheduler_enabled_node_types());
+    if (!empty($scheduler_enabled_types)) {
+      $query = \Drupal::entityQuery('node')
+        ->exists('publish_on')
+        ->condition('publish_on', REQUEST_TIME, '<=')
+        ->condition('type', $scheduler_enabled_types, 'IN')
+        ->sort('publish_on')
+        ->sort('nid');
+      $nids = $query->execute();
+    }
 
     $action = 'publish';
 
@@ -201,12 +206,17 @@ class SchedulerManager {
     $result = FALSE;
 
     // If the time is greater than the time to unpublish a node, unpublish it.
-    $query = \Drupal::entityQuery('node')
-      ->condition('unpublish_on', 0, '>')
-      ->condition('unpublish_on', REQUEST_TIME, '<=');
-    // @todo Change this query to exclude nodes which are not enabled for
-    // unpublishing. See https://www.drupal.org/node/2659824
-    $nids = $query->execute();
+    $nids = [];
+    $scheduler_enabled_types = array_keys(scheduler_get_scheduler_enabled_node_types());
+    if (!empty($scheduler_enabled_types)) {
+      $query = \Drupal::entityQuery('node')
+        ->exists('unpubish_on')
+        ->condition('unpublish_on', REQUEST_TIME, '<=')
+        ->condition('type', $scheduler_enabled_types, 'IN')
+        ->sort('unpublish_on')
+        ->sort('nid');
+      $nids = $query->execute();
+    }
 
     $action = 'unpublish';
 
