From 09eedb385048604ff7965fa883ec2c7b7f1e08e5 Mon Sep 17 00:00:00 2001
From: Mark Moser <MarkAMoser@gmail.com>
Date: Sun, 11 Nov 2018 23:27:09 -0600
Subject: [PATCH] homepage as a menu

---
 functions.php |  2 +-
 home-loop.php | 55 +++++++++++++++++++++++++++++++++------------------
 2 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/functions.php b/functions.php
index 950717e..22f8b69 100644
--- a/functions.php
+++ b/functions.php
@@ -57,7 +57,7 @@ function register_ildi_menus() {
   register_nav_menus(array(
     'header-menu' => __('Header Menu', 'ildi'),
     'utility-menu' => __('Utility Links', 'ildi'),
-    // 'footer-menu' => __('Footer Menu', 'ildi')
+    'homepage-list' => __('HomePage List', 'ildi')
   ));
 }
 
diff --git a/home-loop.php b/home-loop.php
index b13f7f3..3f79f3a 100644
--- a/home-loop.php
+++ b/home-loop.php
@@ -1,28 +1,45 @@
 <div class="grid xs-col-100 sm-col-50 md-col-33 grid-gutter-lg">
 <?php
 
-  $sticky = get_option( 'sticky_posts' );
-  $args = array(
-    'posts_per_page' => 12,
-    'post__in'  => $sticky,
-    'ignore_sticky_posts' => 1
-  );
-  $query = new WP_Query( $args );
+  $homeList = wp_get_nav_menu_items('homepage-list');
 
-  if ( isset($sticky[0]) && $query->have_posts() ) {
-    while ( $query->have_posts() ) {
-      $query->the_post(); ?>
+  if($homeList){
+    foreach($homeList as $item){
+      $post = get_post($item->object_id);
 
-      <section class="home-loop">
-        <a href="<?php echo get_page_link(); ?>"><?php
-          the_title( '<h1>', '</h1>' );
-          the_post_thumbnail();
-        ?></a>
-      </section>
+      ?><section class="home-loop">
+          <a href="<?php echo get_page_link($post); ?>">
+            <h1><?php echo($post->post_title); ?></h1>
+            <?php echo(get_the_post_thumbnail($post)); ?>
+          </a>
+      </section><?php
+    }
 
-    <?php }
+  } else {
+
+    $sticky = get_option( 'sticky_posts' );
+    $args = array(
+      'posts_per_page' => 12,
+      'post__in'  => $sticky,
+      'ignore_sticky_posts' => 1
+    );
+    $query = new WP_Query( $args );
+
+    if ( isset($sticky[0]) && $query->have_posts() ) {
+      while ( $query->have_posts() ) {
+        $query->the_post(); ?>
+
+        <section class="home-loop">
+          <a href="<?php echo get_page_link(); ?>"><?php
+            the_title( '<h1>', '</h1>' );
+            the_post_thumbnail();
+          ?></a>
+        </section>
+
+      <?php }
+    }
+
+    wp_reset_postdata();
   }
-
-  wp_reset_postdata();
 ?>
 </div>