<?php
    header("Content-Type: text/xml");
    require_once('./cms/wp-load.php');
    echo '<?xml version="1.0" encoding="UTF-8"?>';
    
    // 商品
    $products = get_posts(array(
        'post_type'=>'products',
        'numberposts'=>-1
    ));
    // 商品 カテゴリ
    //$products_cat = get_terms('cate');
    // 商品 目的
    //$products_cat2 = get_terms('purpose');
    // 商品 成分
    //$products_cat3 = get_terms('compornent');
    
    // お知らせ
    $info = get_posts(array(
        'post_type'=>'post',
        'numberposts'=>-1
    ));
    // お知らせ カテゴリ
    //$info_cate = get_terms('category');
    
    // コンテンツ
    $contents = get_posts(array(
        'post_type'=>'contents',
        'numberposts'=>-1
    ));
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<url>
		<loc>https://shop.ruamruam.jp/</loc>
		<lastmod><?php echo date('Y-m-d', strtotime($info[0]->post_modified)); ?></lastmod>
		<priority>1.0</priority>
	</url>
    <url>
		<loc>https://shop.ruamruam.jp/products</loc>
		<lastmod><?php echo date('Y-m-d', strtotime($products[0]->post_modified)); ?></lastmod>
		<priority>0.9</priority>
	</url>
    <url>
		<loc>https://shop.ruamruam.jp/products/cate/regular</loc>
		<lastmod><?php echo date('Y-m-d', strtotime($products[0]->post_modified)); ?></lastmod>
		<priority>0.9</priority>
	</url>
<?php
    // 商品
    if( !empty($products) ){
        foreach( $products as $p ) {
            echo '<url>
                <loc>'.get_permalink($p->ID).'</loc>
                <lastmod>'.date('Y-m-d', strtotime($p->post_modified)).'</lastmod>
                <priority>0.9</priority>
            </url>';
        }
    }
    // 商品 カテゴリ
    if( !empty($products_cat) ){
        foreach( $products_cat as $c ) {
            echo '<url>
                <loc>'.get_term_link($c).'</loc>
                <lastmod>'.date('Y-m-d', strtotime($products[0]->post_modified)).'</lastmod>
                <priority>0.9</priority>
            </url>';
        }
    }
    // 商品 目的
    if( !empty($products_cat2) ){
        foreach( $products_cat2 as $c ) {
            echo '<url>
                <loc>'.get_term_link($c).'</loc>
                <lastmod>'.date('Y-m-d', strtotime($products[0]->post_modified)).'</lastmod>
                <priority>0.9</priority>
            </url>';
        }
    }
    // 商品 成分
    if( !empty($products_cat3) ){
        foreach( $products_cat3 as $c ) {
            echo '<url>
                <loc>'.get_term_link($c).'</loc>
                <lastmod>'.date('Y-m-d', strtotime($products[0]->post_date)).'</lastmod>
                <priority>0.9</priority>
            </url>';
        }
    }
    // お客様の声
?>
    <url>
		<loc>https://shop.ruamruam.jp/voice/</loc>
		<lastmod><?php echo date('Y-m-d', strtotime($products[0]->post_date)); ?></lastmod>
		<priority>0.8</priority>
	</url>
<?php
    // お客様の声 商品別
    if( !empty($products) ){
        foreach( $products as $p ) {
            if( $p->comment_status == 'open' && $p->comment_count != '0' ){
            }
            echo '<url>
                <loc>https://shop.ruamruam.jp/voice/detail.php?product_id='.$p->post_name.'</loc>
                <lastmod>'.date('Y-m-d', strtotime($p->post_modified)).'</lastmod>
                <priority>0.8</priority>
            </url>';
        }
    }
    // コンテンツ
    if( !empty($contents) ){
        foreach( $contents as $p ) {
            echo '<url>
                <loc>'.get_permalink($p->ID).'</loc>
                <lastmod>'.date('Y-m-d', strtotime($p->post_modified)).'</lastmod>
                <priority>0.7</priority>
            </url>';
        }
    }
?>
	<url>
		<loc>https://shop.ruamruam.jp/info</loc>
		<lastmod><?php echo date('Y-m-d', strtotime($info[0]->post_date)); ?></lastmod>
		<priority>1.0</priority>
	</url>
<?php
    // お知らせ 記事    
    if( !empty($info) ){
        foreach( $info as $p ) {
            echo '<url>
                <loc>'.get_permalink($p->ID).'</loc>
                <lastmod>'.date('Y-m-d', strtotime($p->post_date)).'</lastmod>
                <priority>0.8</priority>
            </url>';
        }
    }
    // お知らせ カテゴリ
    if( !empty($info_cate) ){
        foreach( $info_cate as $c ) {
            echo '<url>
                <loc>'.get_term_link($c).'</loc>
                <lastmod>'.date('Y-m-d', strtotime($info[0]->post_date)).'</lastmod>
                <priority>0.9</priority>
            </url>';
        }
    }
 
    // 以下静的ページ
?>
    <url>
		<loc>https://shop.ruamruam.jp/herbal-fresh-soap/</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.8</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/about/</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.8</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/guide/</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.7</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/guide/delivery.html</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.7</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/guide/payment.html</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.7</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/guide/cancel.html</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.7</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/guide/point.html</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.7</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/guide/member.html</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.7</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/guide/forget.html</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.7</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/guide/mypage.html</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.7</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/guide/faq.html</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.7</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/contact</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.6</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/contact/</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.6</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/contact_ws/</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.6</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/list/</loc>
		<lastmod>2017-10-19</lastmod>
		<priority>0.6</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/company/</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/privacy/</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://shop.ruamruam.jp/terms/</loc>
		<lastmod>2015-07-28</lastmod>
		<priority>0.5</priority>
	</url>
</urlset>
