<?php $bauen_options = get_option('bauen'); ?>
<?php
/*Template Name:One Page Template*/
 get_header();
 ?>
<?php if(has_nav_menu('main-menu')) {?>
<?php 
    if ( ( $locations = get_nav_menu_locations() ) && $locations['main-menu'] ) {
        $menu = wp_get_nav_menu_object( $locations['main-menu'] );
        $menu_items = wp_get_nav_menu_items($menu->term_id);
        $include = array();
        foreach($menu_items as $item) {
            if($item->object == 'page')
                $include[] = $item->object_id;
        }
        $main_query = new WP_Query( array( 'post_type' => 'page', 'post__in' => $include, 'posts_per_page' => count($include), 'orderby' => 'post__in' ) );
    }
    
    $i = 0;
    while ($main_query->have_posts()) : $main_query->the_post();
     global $post, $separatepages;

    $post_name = $post->post_name;
    
    $post_id = get_the_ID();
     ?>
	 <?php $separatepages = get_post_meta($post->ID,'rnr_open_page',true);

    if (($separatepages != true ))
    { ?>
<?php if(get_post_meta($post->ID,'bauen_page_header_selector_opt',true)!='st1' || get_post_meta($post->ID,'bauen_page_header_selector_opt',true)!='st7'){ ?>

<?php get_template_part('template-parts/header/intro-onepage'); ?>

<?php } ;?>
<?php $i++;}  endwhile; wp_reset_postdata(); ?>
<?php } ;?>
<div class="content-wrapper">

	<!-- Lines -->
	<?php if (Bauen_AfterSetupTheme::return_thme_option('content_lines')=='st2'){ ?>
	<section class="content-lines-wrapper">
		<div class="content-lines-inner">
			<div class="content-lines"></div>
		</div>
	</section>
	<?php } ;?>

<?php if(has_nav_menu('main-menu')) {?>
<?php 
    if ( ( $locations = get_nav_menu_locations() ) && $locations['main-menu'] ) {
        $menu = wp_get_nav_menu_object( $locations['main-menu'] );
        $menu_items = wp_get_nav_menu_items($menu->term_id);
        $include = array();
        foreach($menu_items as $item) {
            if($item->object == 'page')
                $include[] = $item->object_id;
        }
        $main_query = new WP_Query( array( 'post_type' => 'page', 'post__in' => $include, 'posts_per_page' => count($include), 'orderby' => 'post__in' ) );
    }
    
    $i = 0;
    while ($main_query->have_posts()) : $main_query->the_post();
    global $post, $separatepages;

    $post_name = $post->post_name;    
    $post_id = get_the_ID();
     ?>
	<?php $separatepages = get_post_meta($post->ID,'bauen_open_page',true);

    if (($separatepages != true ))
    { ?> 
<?php if(get_post_meta($post->ID,'bauen_page_header_selector_opt',true)=='st1' || get_post_meta($post->ID,'bauen_page_header_selector_opt',true)=='st7'){ ?>	
		<section id="<?php echo $post->post_name;?>" class=" <?php echo $post->post_name;?>" data-scroll-index="<?php echo esc_attr($i);?>">

			<?php global $more; $more = 0; the_content('');?>
		
		</section>
<?php } ;?>

    <?php $i++;}  endwhile; wp_reset_postdata(); ?>
<?php } else { ?>

	<section class="banner-header-custom">
		<div class="container">
			<div class="row">
				<div class="col-md-12 mb-30">
					<h2 class="section-title"><?php esc_html_e('Required','bauen');?></h2>
					<p><?php esc_html_e('Add This Page To "One Page Menu" Location.','bauen');?></p>
					<button class="butn-dark mt-15"><a href="<?php echo esc_url(home_url('/')); ?>wp-admin/nav-menus.php" target="_blank"><span><?php esc_html_e('Click Here','bauen');?></span></a></button>
				</div>
			</div>
		</div>
	</section>

<?php } ;?>
</div>
<?php get_footer(); ?>	