Fix frontpage map page collection code
authorLaury GvR <laury@gaslightmedia.com>
Tue, 21 Aug 2018 21:16:19 +0000 (17:16 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 21 Aug 2018 21:16:19 +0000 (17:16 -0400)
parts/map-section.php

index ddf9f76..b51c5c1 100644 (file)
@@ -4,6 +4,10 @@
     <div id="right-of-map" class="side-of-map"></div><!-- WP CITY PAGE DATA FOR JS PROCESSING -->
 
     <?php
+        
+        // $pages = [  'ocqueoc-falls-bicentennial-pathway', 'thompsons-harbor-state-park', 'leer-road-sinkholes','old-new-presque-isle-lighthouses', 
+        //             'rockport-state-recreation-area','middle-island-lighthouse','little-red-lighthouse','thunder-bay-island-lighthouse', 'norway-ridge-pathway',
+        //             'thunder-bay-national-marine-sanctuary', 'chippewa-hills-pathway', 'negwegon-state-park', 'sturgeon-point-lighthouse', 'visit-alpena'];
         $ocqueocPathway_id      = 77245;
         $thompsonsPark_id       = 77215;
         $leerSinkholes_id       = 69089;
         $pages = [  $ocqueocPathway_id, $thompsonsPark_id, $leerSinkholes_id, $presqueLighthouse_id, 
                     $rockportRecreation_id, $middleLighthouse_id, $littleRed_id, $thunderLighthouse_id, $norwayRidge_id,
                     $thunderSanctuary_id, $chippewaPathway_id, $negwegonPark_id, $sturgeonLighthouse_id, $visitAlpena_id];
-        
-
         $locations = array();
         foreach($pages as $page){
             $args = array(
-                'post_id'     => $page,
+                'ID' => $page,
                 'post_type'   => 'page',
                 'post_status' => 'publish',
                 'numberposts' => 1
             );
-            $location_page = get_posts($args);
-            console.log($location_page);
-            // echo '<pre>', print_r($location_page), '</pre>';
+            
+            $location_page = get_post($page);
             if( !empty($location_page) ){
-                $content = get_excerpt_by_id($location_page[0]->ID, 20);
+                $content = get_excerpt_by_id($location_page->ID, 20);
                 // $content        = get_the_excerpt($location_page[0]->ID);
-                $location_image_id  = get_post_thumbnail_id($location_page[0]->ID);
+                $location_image_id  = get_post_thumbnail_id($location_page->ID);
                 $location_image     = wp_get_attachment_image_src( $location_image_id, 'glm-map-image', true);
-                $location_url       = get_permalink($location_page[0]->ID);
+                $location_url       = get_permalink($location_page->ID);
                 
                 if($location_image_id){
                     $location_image = wp_get_attachment_image_src( $location_image_id, 'glm-map-image', true);
                 } else {
                     $location_image = null;
                 }
-                //console.log($locations);
-                $locations[$location_page[0]->post_name] = array(
-                    'title'     => $location_page[0]->post_title,
-                    'id'        => $location_page[0]->ID,
+                $locations[$location_page->post_name] = array(
+                    'title'     => $location_page->post_title,
+                    'id'        => $location_page->ID,
                     'content'   => $content,
-                    'slug'      => $location_page[0]->post_name,
+                    'slug'      => $location_page->post_name,
                     'image'     => $location_image,
                     'url'       => $location_url
                 );