Add facts slider ordering functionality
authorLaury GvR <laury@gaslightmedia.com>
Wed, 6 Jun 2018 16:53:58 +0000 (12:53 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 6 Jun 2018 16:53:58 +0000 (12:53 -0400)
functions.php
parts/facts-slider.php

index 94549b1..1392c6b 100644 (file)
@@ -238,9 +238,9 @@ function fact_post_type() {
                'label'                 => __( 'Fact', 'text_domain' ),
                'description'           => __( 'Fact information page.', 'text_domain' ),
                'labels'                => $labels,
-               'supports'              => array( 'title', 'editor', 'revisions' ),
+               'supports'              => array( 'title', 'editor', 'revisions', 'page-attributes' ),
                'taxonomies'            => array( 'category' ),
-               'hierarchical'          => false,
+               'hierarchical'          => true,
                'public'                => true,
                'show_ui'               => true,
                'show_in_menu'          => true,
index 1ed07bb..5fbbf2d 100644 (file)
@@ -3,15 +3,19 @@
                         <div id="facts-slider-container">
                             <ul id="facts-slider">
                                 <?php
-                                    // See functions: fact_post_type, "Facts" in admin
-                                    $query = new WP_Query(array(
+                                    // See functions: fact_post_type, "Facts Slider" in admin
+                                    $args = array(
+                                        'numberposts' => -1,
+                                        'orderby' => 'menu_order',
+                                        'order' => 'ASC',
                                         'post_type' => 'facts',
                                         'post_status' => 'publish'
-                                    ));
+                                    );
 
-
-                                    while ($query->have_posts()) {
-                                        $query->the_post();
+                                    $facts_loop = new WP_Query( $args );
+                                    
+                                    while ($facts_loop->have_posts()) {
+                                        $facts_loop->the_post();
                                         $post_id = get_the_ID();
                                         $post_content = get_the_content($post_id);