{"id":4736,"date":"2023-07-21T15:58:50","date_gmt":"2023-07-21T06:58:50","guid":{"rendered":"http:\/\/www.lining-moon.casa\/andplus.co.jp_230822_230809\/?p=4736"},"modified":"2026-02-25T11:10:44","modified_gmt":"2026-02-25T02:10:44","slug":"post-4736","status":"publish","type":"post","link":"https:\/\/code-plus.jp\/gp\/post-4736\/","title":{"rendered":"WordPress\u306e\u6295\u7a3f\u4e00\u89a7\u3084\u56fa\u5b9a\u30da\u30fc\u30b8\u4e00\u89a7\u306b\u3001\u300cView\u6570\u300d\u300c\u30b9\u30e9\u30c3\u30b0\u300d\u300cID\u300d\u300c\u9806\u5e8f\u300d\u5217\u3092\u8ffd\u52a0\u3059\u308b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba"},"content":{"rendered":"<p>WordPress\u306e\u7ba1\u7406\u753b\u9762\u3067\u306f\u3001\u6295\u7a3f\u4e00\u89a7\u3084\u56fa\u5b9a\u30da\u30fc\u30b8\u4e00\u89a7\u306b\u8868\u793a\u3055\u308c\u308b\u5217\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u304d\u307e\u3059\u3002\u4eca\u56de\u306f\u3001\u300cView\u6570\u300d\u3001\u300c\u30b9\u30e9\u30c3\u30b0\u300d\u3001\u300cID\u300d\u3001\u300c\u9806\u5e8f\u300d\u306e4\u3064\u306e\u5217\u3092\u8868\u793a\u3057\u3001\u305d\u308c\u3089\u306e\u5217\u3067\u30bd\u30fc\u30c8\u304c\u53ef\u80fd\u306b\u306a\u308b\u3088\u3046\u306b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\r\n<p>\u305d\u308c\u305e\u308c\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u65b9\u6cd5\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\u3002<\/p>\r\n<h3>View\u6570\u5217\u306e\u8ffd\u52a0\u3068\u30bd\u30fc\u30c8<\/h3>\r\n<p><code>functions.php<\/code> \u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\r\n<pre class=\"language-php\"><code>\r\n  \/\/\u8a18\u4e8b\u306eView\u6570\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u30fb\u66f4\u65b0\u3059\u308b\r\n  function setPostViews() {\r\n    $post_id = get_the_ID();\r\n    $custom_key = 'post_views_count';\r\n    $post_views_count = get_post_meta($post_id, $custom_key, true); \/\/\u73fe\u5728\u306e\u30d3\u30e5\u30fc\u6570\u3092\u53d6\u5f97\r\n    \/\/\u3059\u3067\u306b\u30e1\u30bf\u30c7\u30fc\u30bf\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u3067\u51e6\u7406\u3092\u5206\u3051\u308b\r\n    if ($post_views_count === '') {\r\n      delete_post_meta($post_id, $custom_key);\r\n      add_post_meta($post_id, $custom_key, '0');\r\n    } else {\r\n      $post_views_count++;\r\n      update_post_meta($post_id, $custom_key, $post_views_count);\r\n    }\r\n  }\r\n  add_action('wp_head', 'setPostViews');\r\n  \r\n  \/\/\u6295\u7a3f\u4e00\u89a7\u3068\u56fa\u5b9a\u30da\u30fc\u30b8\u4e00\u89a7\u306b\u300cView\u6570\u300d\u5217\u3092\u8ffd\u52a0\r\n  function add_posts_columns_post_views_count($columns) {\r\n    $columns['post_views_count'] = 'view\u6570';\r\n    echo '&lt;style&gt;.fixed .column-post_views_count {width:80px;}&lt;\/style&gt;';\r\n    return $columns;\r\n  }\r\n  add_filter('manage_posts_columns', 'add_posts_columns_post_views_count');\r\n  add_filter('manage_pages_columns', 'add_posts_columns_post_views_count');\r\n  \r\n  \/\/\u8a18\u4e8b\u306eView\u6570\u3092\u8868\u793a\u3059\u308b\r\n  function custom_posts_columns_post_views_count($column_name, $post_id) {\r\n    if ('post_views_count' == $column_name) {\r\n      $post_id = $post_id ? $post_id : get_the_ID();\r\n      $custom_key = 'post_views_count';\r\n      $post_views_count = get_post_meta($post_id, $custom_key, true);\r\n      if ($post_views_count === '') {\r\n        \/\/\u307e\u3060\u30e1\u30bf\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3057\u3066\u3044\u306a\u3051\u308c\u3070\r\n        delete_post_meta($post_id, $custom_key);\r\n        add_post_meta($post_id, $custom_key, '0');\r\n        $post_views_count = 0;\r\n      }\r\n      echo $post_views_count;\r\n    }\r\n  }\r\n  add_action('manage_posts_custom_column', 'custom_posts_columns_post_views_count', 10, 2);\r\n  add_action('manage_pages_custom_column', 'custom_posts_columns_post_views_count', 10, 2);\r\n  \r\n  \/\/\u30bd\u30fc\u30c8\u53ef\u80fd\u306b\u3059\u308b\r\n  function sort_posts_columns_post_views_count($columns) {\r\n    $columns['post_views_count'] = 'post_views_count';\r\n    return $columns;\r\n  }\r\n  add_filter('manage_edit-post_sortable_columns', 'sort_posts_columns_post_views_count');\r\n  add_filter('manage_edit-page_sortable_columns', 'sort_posts_columns_post_views_count');  \r\n  <\/code><\/pre>\r\n\r\n<h3>\u30b9\u30e9\u30c3\u30b0\u5217\u306e\u8ffd\u52a0\u3068\u30bd\u30fc\u30c8<\/h3>\r\n<p><code>functions.php<\/code> \u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\r\n<pre class=\"language-php\"><code>\r\n\/\/\u8a18\u4e8b\u306eView\u6570\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u30fb\u66f4\u65b0\u3059\u308b\r\nfunction setPostViews() {\r\n  $post_id = get_the_ID();\r\n  $custom_key = 'post_views_count';\r\n  $post_views_count = get_post_meta($post_id, $custom_key, true); \/\/\u73fe\u5728\u306e\u30d3\u30e5\u30fc\u6570\u3092\u53d6\u5f97\r\n  \/\/\u3059\u3067\u306b\u30e1\u30bf\u30c7\u30fc\u30bf\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u3067\u51e6\u7406\u3092\u5206\u3051\u308b\r\n  if ($post_views_count === '') {\r\n    delete_post_meta($post_id, $custom_key);\r\n    add_post_meta($post_id, $custom_key, '0');\r\n  } else {\r\n    $post_views_count++;\r\n    update_post_meta($post_id, $custom_key, $post_views_count);\r\n  }\r\n}\r\nadd_action('wp_head', 'setPostViews');\r\n\r\n\/\/\u6295\u7a3f\u4e00\u89a7\u3068\u56fa\u5b9a\u30da\u30fc\u30b8\u4e00\u89a7\u306b\u300cView\u6570\u300d\u5217\u3092\u8ffd\u52a0\r\nfunction add_posts_columns_post_views_count($columns) {\r\n  $columns['post_views_count'] = 'view\u6570';\r\n  echo '<style>.fixed .column-post_views_count {width:80px;}<\/style>';\r\n  return $columns;\r\n}\r\nadd_filter('manage_posts_columns', 'add_posts_columns_post_views_count');\r\nadd_filter('manage_pages_columns', 'add_posts_columns_post_views_count');\r\n\r\n\/\/\u8a18\u4e8b\u306eView\u6570\u3092\u8868\u793a\u3059\u308b\r\nfunction custom_posts_columns_post_views_count($column_name, $post_id) {\r\n  if ('post_views_count' == $column_name) {\r\n    $post_id = $post_id ? $post_id : get_the_ID();\r\n    $custom_key = 'post_views_count';\r\n    $post_views_count = get_post_meta($post_id, $custom_key, true);\r\n    if ($post_views_count === '') {\r\n      \/\/\u307e\u3060\u30e1\u30bf\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3057\u3066\u3044\u306a\u3051\u308c\u3070\r\n      delete_post_meta($post_id, $custom_key);\r\n      add_post_meta($post_id, $custom_key, '0');\r\n      $post_views_count = 0;\r\n    }\r\n    echo $post_views_count;\r\n  }\r\n}\r\nadd_action('manage_posts_custom_column', 'custom_posts_columns_post_views_count', 10, 2);\r\nadd_action('manage_pages_custom_column', 'custom_posts_columns_post_views_count', 10, 2);\r\n\r\n\/\/\u30bd\u30fc\u30c8\u53ef\u80fd\u306b\u3059\u308b\r\nfunction sort_posts_columns_post_views_count($columns) {\r\n  $columns['post_views_count'] = 'post_views_count';\r\n  return $columns;\r\n}\r\nadd_filter('manage_edit-post_sortable_columns', 'sort_posts_columns_post_views_count');\r\nadd_filter('manage_edit-page_sortable_columns', 'sort_posts_columns_post_views_count');\r\n<\/code><\/pre>\r\n\r\n<h3>\u30b9\u30e9\u30c3\u30b0\u5217\u306e\u8ffd\u52a0\u3068\u30bd\u30fc\u30c8<\/h3>\r\n<p><code>functions.php<\/code> \u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\r\n<pre class=\"language-php\"><code>\r\n\/* \u6295\u7a3f\u4e00\u89a7\u3068\u56fa\u5b9a\u30da\u30fc\u30b8\u4e00\u89a7\u306b\u30b9\u30e9\u30c3\u30b0\u5217\u3092\u8ffd\u52a0 *\/\r\nfunction add_post_page_column_title($columns) {\r\n  $columns['slug'] = '\u30b9\u30e9\u30c3\u30b0';\r\n  echo '<style>.fixed .column-slug {width:10%;}<\/style>';\r\n  return $columns;\r\n}\r\nadd_filter('manage_posts_columns', 'add_post_page_column_title');\r\nadd_filter('manage_pages_columns', 'add_post_page_column_title');\r\n\r\nfunction add_post_page_column($column_name, $post_id) {\r\n  if ($column_name == 'slug') {\r\n    $post = get_post($post_id);\r\n    $slug = $post->post_name;\r\n    echo esc_attr($slug);\r\n  }\r\n}\r\nadd_action('manage_posts_custom_column', 'add_post_page_column', 10, 2);\r\nadd_action('manage_pages_custom_column', 'add_post_page_column', 10, 2);\r\n\r\n\/\/ \u30b9\u30e9\u30c3\u30b0\u5217\u306e\u30bd\u30fc\u30c8\r\nfunction add_slug_sortable_column( $columns ) {\r\n    $columns['slug'] = 'slug';\r\n    return $columns;\r\n}\r\nadd_filter('manage_edit-post_sortable_columns', 'add_slug_sortable_column');\r\nadd_filter('manage_edit-page_sortable_columns', 'add_slug_sortable_column');\r\n<\/code><\/pre>\r\n\r\n<h3>ID\u5217\u306e\u8ffd\u52a0\u3068\u30bd\u30fc\u30c8<\/h3>\r\n<p><code>functions.php<\/code> \u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\r\n<pre class=\"language-php\"><code>\r\n\/* \u6295\u7a3f\u4e00\u89a7\u3068\u56fa\u5b9a\u30da\u30fc\u30b8\u4e00\u89a7\u306bID\u5217\u3092\u8ffd\u52a0 *\/\r\nfunction add_post_id_column_title($columns) {\r\n  $columns['post_id'] = 'ID';\r\n  echo '<style>.fixed .column-post_id {width:5%;}<\/style>';\r\n  return $columns;\r\n}\r\nadd_filter('manage_posts_columns', 'add_post_id_column_title');\r\nadd_filter('manage_pages_columns', 'add_post_id_column_title');\r\n\r\nfunction add_post_id_column($column_name, $post_id) {\r\n  if ($column_name == 'post_id') {\r\n    echo $post_id;\r\n  }\r\n}\r\nadd_action('manage_posts_custom_column', 'add_post_id_column', 10, 2);\r\nadd_action('manage_pages_custom_column', 'add_post_id_column', 10, 2);\r\n\r\n\/\/ ID\u5217\u306e\u30bd\u30fc\u30c8\r\nfunction add_post_id_sortable_column( $columns ) {\r\n    $columns['post_id'] = 'ID';\r\n    return $columns;\r\n}\r\nadd_filter('manage_edit-post_sortable_columns', 'add_post_id_sortable_column');\r\nadd_filter('manage_edit-page_sortable_columns', 'add_post_id_sortable_column');  \r\n<\/code><\/pre>\r\n\r\n\r\n<h3>\u9806\u5e8f\u5217\u306e\u8ffd\u52a0\u3068\u30bd\u30fc\u30c8<\/h3>\r\n<p><code>functions.php<\/code> \u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\r\n<pre class=\"language-php\"><code>\r\n\/* \u6295\u7a3f\u4e00\u89a7\u3068\u56fa\u5b9a\u30da\u30fc\u30b8\u4e00\u89a7\u306b\u300c\u9806\u5e8f\u300d\u5217\u3092\u8ffd\u52a0 *\/\r\nfunction add_menu_order_column($columns) {\r\n  $columns['menu_order'] = '\u9806\u5e8f';\r\n  echo '<style>.fixed .column-menu_order {width:70px;}<\/style>';\r\n  return $columns;\r\n}\r\nadd_filter('manage_edit-page_columns', 'add_menu_order_column');\r\nadd_filter('manage_posts_columns', 'add_menu_order_column');\r\n\r\n\/\/\u300c\u9806\u5e8f\u300d\u306e\u5024\u3092\u8868\u793a\r\nfunction show_menu_order_column($name, $post_id) {\r\n  if ('menu_order' == $name) {\r\n    $order = get_post_field('menu_order', $post_id);\r\n    echo $order;\r\n  }\r\n}\r\nadd_action('manage_pages_custom_column', 'show_menu_order_column', 10, 2);\r\nadd_action('manage_posts_custom_column', 'show_menu_order_column', 10, 2);\r\n\r\n\/\/\u30bd\u30fc\u30c8\u53ef\u80fd\u306b\u3059\u308b\r\nfunction sort_menu_order_column($columns) {\r\n  $columns['menu_order'] = 'menu_order';\r\n  return $columns;\r\n}\r\nadd_filter('manage_edit-post_sortable_columns', 'sort_menu_order_column');\r\nadd_filter('manage_edit-page_sortable_columns', 'sort_menu_order_column');\r\n<\/code><\/pre>\r\n\r\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3092 <code>functions.php<\/code> \u306b\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3001\u300cView\u6570\u300d\u3001\u300c\u30b9\u30e9\u30c3\u30b0\u300d\u3001\u300cID\u300d\u3001\u300c\u9806\u5e8f\u300d\u306e4\u3064\u306e\u5217\u304c\u6295\u7a3f\u4e00\u89a7\u3068\u56fa\u5b9a\u30da\u30fc\u30b8\u4e00\u89a7\u306b\u8ffd\u52a0\u3055\u308c\u3001\u5404\u5217\u3067\u30bd\u30fc\u30c8\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u306a\u304a\u3001\u5404\u5217\u306e\u30bd\u30fc\u30c8\u6a5f\u80fd\u306f\u3001\u305d\u308c\u305e\u308c\u306e\u5217\u306e\u30d8\u30c3\u30c0\u30fc\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3053\u3068\u3067\u52d5\u4f5c\u3057\u307e\u3059\u3002<\/p>","protected":false},"excerpt":{"rendered":"WordPress\u306e\u7ba1\u7406\u753b\u9762\u3067\u306f\u3001\u6295\u7a3f\u4e00\u89a7\u3084\u56fa\u5b9a\u30da\u30fc\u30b8\u4e00\u89a7\u306b\u8868\u793a\u3055\u308c\u308b\u5217\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u304d\u307e\u3059\u3002\u4eca\u56de\u306f\u3001\u300cView\u6570\u300d\u3001\u300c\u30b9\u30e9\u30c3\u30b0\u300d\u3001\u300cID\u300d\u3001\u300c\u9806\u5e8f\u300d\u306e4\u3064\u306e\u5217\u3092\u8868\u793a\u3057\u3001\u305d\u308c\u3089\u306e\u5217\u3067\u30bd\u30fc\u30c8\u304c\u53ef\u80fd\u306b\u306a\u308b\u3088\u3046\u306b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba[...]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","footnotes":"","vk-ltc-link":"","vk-ltc-target":"0"},"categories":[13],"tags":[],"class_list":["post-4736","post","type-post","status-publish","format-standard","category-wordpress"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/4736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/comments?post=4736"}],"version-history":[{"count":0,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/posts\/4736\/revisions"}],"wp:attachment":[{"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/media?parent=4736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/categories?post=4736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-plus.jp\/gp\/wp-json\/wp\/v2\/tags?post=4736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}