// 年別アーカイブ取得 $args_year = array( 'type' => 'yearly', 'show_post_count' => 0, 'post_type' => $post_type, 'cat' => $cat, 'format' => 'html', 'echo' => 0, ); $archives_year = wp_get_archives($args_year); // 年毎に分割 $archives_year_array = explode("\n", $archives_year); foreach ($archives_year_array as $archive_year_tag) { // 要素ごとに分解 preg_match("/()(\d{4})(<.*?>)/", $archive_year_tag, $elements); $archives_year_map[$elements[2]] = $archive_year_tag; } // 月別アーカイブ取得 $args_month = array( 'type' => 'monthly', 'show_post_count' => 1, 'post_type' => $post_type, 'cat' => $cat, 'format' => 'html', 'echo' => 0, ); $archives_month = wp_get_archives($args_month); // 月毎に分割 $archives_month_array = explode("\n", $archives_month); $before_year = ""; foreach ($archives_month_array as $archive_month_tag) { if ($archive_month_tag == "") { // 最後に空白のゴミが入るのでスキップ break; } // 要素毎に分解 preg_match_all("/<.*?>/", $archive_month_tag, $tags); preg_match("/(\d{4})年/", $archive_month_tag, $year); preg_match("/(\d+)月/", $archive_month_tag, $month); preg_match("/\((\d+)\)/", $archive_month_tag, $count); $archives[$year[1]][$month[1]] = $count[1]; } return $archives; } } // ページ名とスラッグ取得 if (!function_exists('get_page_slug')) { function get_page_slug() { global $post; // ホーム・404など、下の条件に該当しないページでも配列を返す $pages = array( 'title' => '', 'slug' => '', 'parent-name' => '', 'parent-slug' => '', 'type' => '' ); // ポストタイプを取得 $post_type = get_post_type($post); if (is_page()) { $page = get_post(get_the_ID()); $pages['title'] = $page->post_title; $pages['slug'] = $page->post_name; $parent_id = $page->post_parent; //親ページのIDを取得 $pages['parent-name'] = get_post($parent_id)->post_title; $pages['parent-slug'] = get_post($parent_id)->post_name; $pages['type'] = 'page'; } elseif (is_category()) { $cateName = single_cat_title('', false); $cateId = get_cat_ID($cateName); $category = get_category($cateId); $pages['term_id'] = $category->term_id; $pages['title'] = $category->name; $pages['slug'] = $category->slug; //一番上の親カテゴリ $ancestor = array_pop(get_ancestors($category->term_id, 'category')); $pages['parent-name'] = get_category($ancestor)->name; $pages['parent-slug'] = get_category($ancestor)->slug; $pages['type'] = 'category'; } elseif (is_post_type_archive()) { $pages['title'] = post_type_archive_title('', false); $pages['slug'] = get_post_type_object($post_type)->name; } elseif (is_date()) { if (is_day()) { $title .= get_query_var('year') . '年 '; $title .= get_query_var('monthnum') . '月 '; $title .= get_query_var('day') . '日'; } elseif (is_month()) { $title .= get_query_var('year') . '年 '; $title .= get_query_var('monthnum') . '月 '; } elseif (is_year()) { $title .= get_query_var('year') . '年 '; } $pages['title'] = $title; $pages['slug'] = get_post_type_object($post_type)->name; } elseif (is_singular($post_type)) { $cates = get_the_category(); $pages['title'] = $cates[0]->name; // $pages['title'] = get_post_type_object( $post_type )->label; $pages['slug'] = $cates[0]->slug; //一番上の親カテゴリ $ancestor = array_pop(get_ancestors($cates[0]->term_id, 'category')); $pages['parent-name'] = get_category($ancestor)->name; $pages['parent-slug'] = get_category($ancestor)->slug; $pages['type'] = 'single'; // カスタムポスト記事ページ $obj = get_post_type_object($post_type); if ($obj->has_archive == true) { $pages['title'] = get_post_type_object($post_type)->label; $pages['slug'] = $post_type; //一番上の親カテゴリ $ancestor = array_pop(get_ancestors($cates[0]->term_id, 'category')); $pages['parent-name'] = get_category($ancestor)->name; $pages['parent-slug'] = get_category($ancestor)->slug; $pages['type'] = 'single'; } } return $pages; } } /* 更新チェック * ---------------------------------------- */ if (!function_exists('chk_update_content')) { function chk_update_content($target) { $update = false; $args = array( 'post_type' => 'post', 'category_name' => $target, 'posts_per_page' => 1, ); $the_query = get_posts($args); //var_dump($the_query); //カテゴリの場合 if (count($the_query) > 0) { foreach ($the_query as $post) { setup_postdata($post); // 最新記事は7日間表示 $days = 7; $today = date_i18n('U'); $entry = strtotime($post->post_modified); $total = date('U', ($today - $entry)) / 86400; if ($days > $total) { $update = true; } } } else { wp_reset_query(); //固定ページの場合 $args = array( 'post_type' => 'page', 'pagename' => $target, 'posts_per_page' => 1, ); $the_query = get_posts($args); foreach ($the_query as $post) { setup_postdata($post); // 最新記事は7日間表示 $days = 7; $today = date_i18n('U'); $entry = strtotime($post->post_modified); $total = date('U', ($today - $entry)) / 86400; if ($days > $total) { $update = true; } } } wp_reset_query(); if ($update === true) { return 'class="update"'; } else { return false; } } } // 新着(NEW)を表示する if (!function_exists('post_date_new')) { function post_date_new($postId = '', $days = 7) { <br /> <b>Fatal error</b>: Uncaught Error: Call to undefined function wmp_title() in /home/gift001/takiservice.co.jp/public_html/cms/design/themes/doc/include/doctype.php:5 Stack trace: #0 /home/gift001/takiservice.co.jp/public_html/cms/wp-includes/template.php(882): require() #1 /home/gift001/takiservice.co.jp/public_html/cms/wp-includes/template.php(815): load_template('/home/gift001/t...', false, Array) #2 /home/gift001/takiservice.co.jp/public_html/cms/wp-includes/general-template.php(206): locate_template(Array, true, false, Array) #3 /home/gift001/takiservice.co.jp/public_html/cms/design/themes/doc/index.php(2): get_template_part('include/doctype') #4 /home/gift001/takiservice.co.jp/public_html/cms/wp-includes/template-loader.php(132): include('/home/gift001/t...') #5 /home/gift001/takiservice.co.jp/public_html/cms/wp-blog-header.php(19): require_once('/home/gift001/t...') #6 /home/gift001/takiservice.co.jp/public_html/index.php(17): require('/home/gift001/t...') #7 {main} thrown in <b>/home/gift001/takiservice.co.jp/public_html/cms/design/themes/doc/include/doctype.php</b> on line <b>5</b><br />