adding output for rooms custom post types
authorAnthony Talarico <talarico@gaslightmedia.com>
Mon, 14 May 2018 15:48:03 +0000 (11:48 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Mon, 14 May 2018 15:48:03 +0000 (11:48 -0400)
adding custom fields output for the rooms page

inc/rooms.php
rooms.php

index 101135a..adcd638 100644 (file)
@@ -67,7 +67,7 @@ function rooms_custom_post_type() {
         'label'                 => __( GLM_ROOM_SINGLE ),
         'description'           => __( 'Custom ' . GLM_ROOM_PLURAL ),
         'labels'                => $labels,
-        'supports'              => array( 'title', 'thumbnail', 'revisions', 'editor', 'author', 'page-attributes','excerpt'),
+        'supports'              => array( 'title', 'thumbnail', 'revisions', 'editor', 'page-attributes'),
         'hierarchical'          => true,
         'public'                => true,
         'show_ui'               => true,
index f119d68..dd72ee6 100644 (file)
--- a/rooms.php
+++ b/rooms.php
@@ -5,39 +5,82 @@
  * @package accesspress_parallax
  */
  
-get_header();?>
+get_header();
+    global $post;
+    $taxonomy = 'rooms_category';
+    $terms = get_terms($taxonomy);
+    $post = get_post($post->id); 
+    $content = apply_filters('the_content', $post->post_content); 
+
+?>
  
  <div class="mid-content">
        <div id="primary" class="content-area">
                <main id="main" class="site-main">
-            <div id="rooms-list">
-                <?php
-                    $query = new WP_Query(array(
-                        'post_type'         => 'glm-rooms',
-                        'post_status'       => 'publish',
-                        'posts_per_page'    => -1,
-                        'orderby'           => 'menu_order'
-                    ));
-                    
-                    while ($query->have_posts()) { 
-                        $query->the_post(); ?>
-                            <h3 class="room-title"> <?php the_title(); ?></h3>
-                            <div class="room-content">
-                                <?php the_content(); ?>
-                                <div class="room-amenities">
-                                    <?php the_excerpt(); ?>
+            <?php echo $content; ?>
+            <div id="rooms-tabs">
+                <ul>
+                    <?php 
+                        foreach($terms as $term){
+                            echo "<li><a href='#$term->name'>$term->name</a></li>";
+                        }
+                    ?>
+                </ul>
+                <?php 
+                foreach($terms as $term){
+                    echo "<div id='$term->name'>";
+                
+                        $query = new WP_Query(array(
+                            'post_type'         => 'glm-rooms',
+                            'post_status'       => 'publish',
+                            'posts_per_page'    => -1,
+                            'orderby'           => 'menu_order',
+                            'tax_query' => array(
+                                array(
+                                    'taxonomy' => 'rooms_category',
+                                    'field' => 'term_id',
+                                    'terms' => $term->term_id
+                                )
+                            )
+                        )); ?>
+                        <div class="room-accordian">
+                            <?php while ($query->have_posts()) { 
+                            $query->the_post(); ?>
+                                <h3 class="room-title"> <?php the_title(); ?></h3>
+                                <div class="room-content">
+                                    <div class="room-info">
+                                        <?php echo get_field('room_info',get_the_id()); ?>
+                                    </div>
+                                    <div class="room-amenities room-accordian">
+                                        <h3>Gallery</h3>
+                                        <div>
+                                            <?php the_content(); ?>
+                                        </div>
+                                    </div>
+                                    <div class="room-amenities room-accordian">
+                                        <h3>Ameneties</h3>
+                                        <div>
+                                            <?php echo get_field('amenities',get_the_id()); ?>
+                                        </div>
+                                    </div>
                                 </div>
-                            </div>
-                            
-                    <?php } ?> 
-                    <?php wp_reset_query();?>
+                            <?php } ?> 
+                            <?php wp_reset_query();?>
+                        </div>
+                    </div>
+                <?php } ?>
             </div>
                </main><!-- #main -->
        </div><!-- #primary -->
 </div>
 <script>
     jQuery( function() {
-    jQuery( "#rooms-list" ).accordion();
-  } );
+        jQuery( ".room-accordian" ).accordion({
+            collapsible: true,
+            active: false,
+            heightStyle: "content"
+        });
+        jQuery( "#rooms-tabs" ).tabs();
+    });
 </script>
 <?php get_footer();
\ No newline at end of file