{"id":481,"date":"2020-05-11T21:51:57","date_gmt":"2020-05-11T12:51:57","guid":{"rendered":"https:\/\/memo.baseline-lib.com\/?p=481"},"modified":"2021-02-05T18:52:13","modified_gmt":"2021-02-05T09:52:13","slug":"wp-%e3%83%af%e3%83%bc%e3%83%89%e3%83%97%e3%83%ac%e3%82%b9%e3%83%aa%e3%83%95%e3%82%a1%e3%83%ac%e3%83%b3%e3%82%b9","status":"publish","type":"post","link":"https:\/\/memo.baseline-lib.com\/?p=481","title":{"rendered":"WP \u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9"},"content":{"rendered":"<h2>\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u3067\u6a29\u9650\u8005\u3054\u3068\u306b\u7279\u5b9a\u306e\u6a5f\u80fd\u3092\u4ed8\u4e0e\u3059\u308b<\/h2>\n<pre class=\"brush: php; highlight: [1]; tab-size: 2; title: functions.php; notranslate\" title=\"functions.php\">\r\n\/\/ \u30e6\u30fc\u30b6\u30fc\u6a29\u9650\u3092\u4ed8\u4e0e\u3059\u308b\r\nfunction add_theme_caps(){\r\n  $role = get_role( 'editor' ); \/\/'\u6a29\u9650\u8005'\r\n  $role-&gt;add_cap( 'list_users' ); \/\/\u4ed8\u4e0e\u3059\u308b\u6a5f\u80fd\r\n}\r\nadd_action( 'admin_init', 'add_theme_caps' );\r\n<\/pre>\n<p>\u7ba1\u7406\u8005 : administrator<br \/>\n\u7de8\u96c6\u3000 : editor<br \/>\n\u6295\u7a3f\u8005 : author<br \/>\n\u5bc4\u7a3f\u8005 : contributor<br \/>\n\u8cfc\u8aad\u8005 : subscriber<br \/>\n<a href=\"https:\/\/www.nxworld.net\/wordpress\/wp-customize-user-role.html\" target=\"_blank\">\u6a29\u9650\u3092\u4ed8\u4e0e\u3059\u308b\u8a18\u8ff0<\/a><br \/>\n<a href=\"https:\/\/wpdocs.osdn.jp\/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9\/add_cap\" target=\"_blank\">\u6a29\u9650\u3092\u4ed8\u4e0e\u3059\u308b\u8a18\u8ff0<\/a><br \/>\n<a href=\"https:\/\/wpdocs.osdn.jp\/%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E3%81%AE%E7%A8%AE%E9%A1%9E%E3%81%A8%E6%A8%A9%E9%99%90#Capability_vs._Role_Table\">\u6a29\u9650\u3092\u4ed8\u4e0e\u306e\u4e00\u89a7<\/a><\/p>\n<p><a href=\"https:\/\/wpdocs.osdn.jp\/%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E3%81%AE%E7%A8%AE%E9%A1%9E%E3%81%A8%E6%A8%A9%E9%99%90#.E7.B7.A8.E9.9B.86.E8.80.85\">\u4ed8\u4e0e\u3059\u308b\u6a29\u9650\u4e00\u89a7<\/a><\/p>\n<h2>\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u3067\u30e6\u30fc\u30b6\u30fc\u4e00\u89a7\u3092\u8868\u793a\u3055\u305b\u308b\u65b9\u6cd5<\/h2>\n<pre class=\"brush: php; title: \u8868\u793a\u3055\u305b\u308b\u30d5\u30a1\u30a4\u30eb.php; notranslate\" title=\"\u8868\u793a\u3055\u305b\u308b\u30d5\u30a1\u30a4\u30eb.php\">\r\n&lt;?php $users = get_users(array(\r\n      'orderby'=&gt;ID,\r\n      'order'=&gt;ASC,\r\n      'exclude'=&gt;array(1,3) \/\/\u8868\u793a\u9664\u5916\u3057\u305f\u3044\u30e6\u30fc\u30b6\u30fcID\r\n      ));?&gt;\r\n\/\/\u8868\u793a\u7b87\u6240\r\n&lt;ul&gt;\r\n  &lt;?php foreach($users as $user):\r\n    $uid = $user-&gt;ID;\r\n    ?&gt;\r\n  &lt;li&gt;&lt;a href=&quot;&lt;?php echo get_bloginfo(&quot;url&quot;) . '\/?author=' . $uid ?&gt;&quot;&gt;\r\n    &lt;strong&gt;&lt;?php echo $user-&gt;display_name ;?&gt;&lt;\/strong&gt;\r\n  &lt;\/a&gt;&lt;\/li&gt;\r\n\r\n&lt;\/ul&gt;\r\n\r\n<\/pre>\n<h2>\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u6539\u5909<\/h2>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#i\"><span class=\"toc_number toc_depth_1\">1<\/span> \u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u306b\u9805\u76ee\u3092\u767b\u9332\u3059\u308b<\/a><\/li><li><a href=\"#i-2\"><span class=\"toc_number toc_depth_1\">2<\/span> \u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u306b\u767b\u9332\u3057\u305f\u60c5\u5831\u3092\u51fa\u529b\u3059\u308b\u65b9\u6cd5<\/a><\/li><li><a href=\"#i-3\"><span class=\"toc_number toc_depth_1\">3<\/span> \u629c\u7c8b\u3059\u308b\u6587\u5b57\u6570\u3092\u5909\u66f4\u3059\u308b<\/a><\/li><\/ul><\/div>\n<h3><span id=\"i\">\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u306b\u9805\u76ee\u3092\u767b\u9332\u3059\u308b<\/span><\/h3>\n<pre class=\"brush: php; title: function.php; notranslate\" title=\"function.php\">\r\nfunction my_user_meta($item){\r\n\/\/\u9805\u76ee\u306e\u8ffd\u52a0\r\n$item['twitter'] = 'twitter';\r\n$item['facebook'] = '\u30d5\u30a7\u30a4\u30b9\u30d6\u30c3\u30af';\r\n$item['insta'] = '\u30a4\u30f3\u30b9\u30bf\u30b0\u30e9\u30e0';\r\nreturn $item;\r\n}\r\nadd_filter('user_contactmethods', 'my_user_meta', 10, 1);\r\n<\/pre>\n<h3><span id=\"i-2\">\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u306b\u767b\u9332\u3057\u305f\u60c5\u5831\u3092\u51fa\u529b\u3059\u308b\u65b9\u6cd5<\/span><\/h3>\n<p>\u203bauthor.php\u3067\u3057\u304b\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093<\/p>\n<pre class=\"brush: php; title: author.php; notranslate\" title=\"author.php\">\r\n&lt;?php the_author_meta(twitter, $author);?&gt; \/\/\u30c4\u30a4\u30c3\u30bf\u30fc\u60c5\u5831\r\n&lt;?php the_author_meta(facebook, $author);?&gt; \/\/\u30d5\u30a7\u30a4\u30b9\u30d6\u30c3\u30af\u60c5\u5831\r\n&lt;?php the_author_meta(insta, $author);?&gt; \/\/\u30a4\u30f3\u30b9\u30bf\u30b0\u30e9\u30e0\u60c5\u5831\r\n<\/pre>\n<p>\u4ed6\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u306e\u51fa\u529b\u65b9\u6cd5<\/p>\n<pre class=\"brush: php; title: page.php\u3084single.php\u3001\u4ed6\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb; notranslate\" title=\"page.php\u3084single.php\u3001\u4ed6\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\">\r\n&lt;ul&gt;\r\n  &lt;?php $args = array(\r\n  'orderby'=&gt;ID, \/\/\u30e6\u30fc\u30b6\u30fcID\u3092\u53d6\u5f97\r\n  'order'=&gt;ASC, \/\/\u65b0\u7740\u9806\r\n  'role__not_in'=&gt;array('editor','administrator'), \/\/\u7279\u5b9a\u306e\u6a29\u9650\u306e\u30e6\u30fc\u30b6\u30fc\u306f\u8868\u793a\u3055\u305b\u306a\u3044\u3002\r\n  );\r\n  $user_query = new WP_User_Query( $args, );\r\n  ?&gt;\r\n\r\n  &lt;?php if(!empty($user_query-&gt;results)): foreach($user_query-&gt;results as $user):?&gt;\r\n  &lt;li&gt;&lt;a href=&quot;&lt;?php echo get_bloginfo(&quot;url&quot;) . '\/?author=' . $user-&gt;ID;?&gt;&quot;&gt;\r\n  &lt;?php\r\n  $field01 = get_field('cast_img01', 'user_' . $user-&gt;ID); \/\/\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30fc\u30eb\u30c9\u30e6\u30fc\u30b6\u30fc\u53d6\u5f97\u8868\u793a\r\n  $url01 = $field01['url'];\r\n  ?&gt;\r\n    &lt;img src=&quot;&lt;?php echo $url01;?&gt;&quot;&gt;\r\n    &lt;strong&gt;&lt;?php echo $user-&gt;display_name;?&gt;&lt;\/strong&gt;\/\/ \u30e6\u30fc\u30b6\u30fc\u540d\r\n    &lt;strong&gt;&lt;?php echo $user-&gt;description;?&gt;&lt;\/strong&gt; \/\/\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u60c5\u5831\r\n    &lt;strong&gt;&lt;?php echo $user-&gt;twitter;?&gt;&lt;\/strong&gt;\/\/\u30c4\u30a4\u30c3\u30bf\u30fc\r\n  &lt;\/a&gt;&lt;\/li&gt;\r\n&lt;?php endforeach; else:?&gt;\r\n&lt;li&gt;\u305f\u3060\u3044\u307e\u6e96\u5099\u4e2d&lt;\/li&gt;\r\n&lt;?php endif;?&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\n<p><a href=\"https:\/\/www.webopixel.net\/wordpress\/136.html\">\u53c2\u8003\u30b5\u30a4\u30c8<\/a><\/p>\n<h2>\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3067\u4e0d\u8981\u306a\u5165\u529b\u9805\u76ee\u3092\u975e\u8868\u793a\u306b\u3059\u308b\u65b9\u6cd5<\/h2>\n<p>\u7ba1\u7406\u753b\u9762\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3067\u691c\u8a3c\u30dc\u30bf\u30f3\u3067id\u3084class\u3092\u78ba\u8a8d\u3057\u3066\u975e\u8868\u793a\u306e\u6307\u5b9a\u3092\u3059\u308b<\/p>\n<pre class=\"brush: php; title: function.php; notranslate\" title=\"function.php\">\r\nfunction user_profile_hide_style() {\r\n  echo '&lt;style&gt;\r\n  #your-profile .user-rich-editing-wrap, \/* \u30d3\u30b8\u30e5\u30a2\u30eb\u30a8\u30c7\u30a3\u30bf\u30fc *\/\r\n  #your-profile .user-comment-shortcuts-wrap, \/* \u30ad\u30fc\u30dc\u30fc\u30c9\u30b7\u30e7\u30fc\u30c8\u30ab\u30c3\u30c8 *\/\r\n  #your-profile .show-admin-bar, \/* \u30c4\u30fc\u30eb\u30d0\u30fc *\/\r\n  #your-profile .user-first-name-wrap, \/* \u540d *\/\r\n  #your-profile .user-last-name-wrap, \/* \u59d3 *\/\r\n  #your-profile .user-profile-picture, \/* \u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u5199\u771f *\/\r\n  #your-profile .user-url-wrap, \/* url *\/\r\n  #your-profile .user-sessions-wrap \/* \u30bb\u30c3\u30b7\u30e7\u30f3 *\/ {\r\n    display: none;\r\n  }\r\n  &lt;\/style&gt;'.PHP_EOL;\r\n}\r\nadd_action('admin_print_styles', 'user_profile_hide_style');\r\n<\/pre>\n<h2>\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u7528\u8a9e<\/h2>\n<p>\u30fb\u30bf\u30af\u30bd\u30ce\u30df\u30fc<br \/>\n\u5de6\u30e1\u30cb\u30e5\u30fc\u306e\u89aa\u9805\u76ee\u306e\u5b50\u9805\u76ee<br \/>\n\u30fb\u30bf\u30fc\u30e0<br \/>\n\u5b50\u9805\u76ee\u5185\u306e\u30ab\u30c6\u30b4\u30ea\u30fc<br \/>\n<a href=\"http:\/\/redline.hippy.jp\/restart\/wordpress\/post-335.php\" rel=\u201cnoopener\u201d>\u53c2\u8003\u30b5\u30a4\u30c8<\/a><\/p>\n<h2>\u8a18\u4e8b\u672c\u6587\u306e\u6587\u5b57\u7701\u7565\u306e\u8a18\u8ff0\u65b9\u6cd5<\/h2>\n<p>the_excerpt()\u3067\u53d6\u5f97\u3057\u305f\u629c\u7c8b\u306f\u8a18\u4e8b\u672c\u6587\u306e\u6700\u521d\u3082\u6587\u5b57\u3092\u629c\u7c8b\u3057\u8a18\u4e8b\u4e00\u89a7\u3067\u8868\u793a\u53ef\u80fd<br \/>\n\u30fb\u81ea\u52d5\u7684\u306b110\u6587\u5b57\u3067\u7701\u7565\u3055\u308c\u3001\u4ee5\u964d\u306e\u6587\u5b57\u306f&#8230;\u3067\u8868\u793a\u3055\u308c\u308b\u3002<br \/>\n\u8a18\u8ff0\u65b9\u6cd5<\/p>\n<pre class=\"brush: php; title: \u8868\u793a\u30d5\u30a1\u30a4\u30ebindex.php\u306a\u3069; notranslate\" title=\"\u8868\u793a\u30d5\u30a1\u30a4\u30ebindex.php\u306a\u3069\">\r\n\/\/\u8868\u793a\u3055\u305b\u305f\u3044\u30d5\u30a1\u30a4\u30eb\u306b\u4ee5\u4e0b\u3092\u8a18\u8ff0\r\n&lt;?php the_excerpt(); ?&gt;\r\n<\/pre>\n<h3><span id=\"i-3\">\u629c\u7c8b\u3059\u308b\u6587\u5b57\u6570\u3092\u5909\u66f4\u3059\u308b<\/span><\/h3>\n<p>\u629c\u7c8b\u3059\u308b\u6587\u5b57\u3092\u5909\u66f4\u3057\u305f\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u8a18\u8ff0\u3092function.php\u306b\u8a18\u8ff0\u3059\u308b<\/p>\n<pre class=\"brush: php; title: function.php; notranslate\" title=\"function.php\">\r\nfunction twpp_change_excerpt_length($length) {\r\n  return 50;\r\n}\r\nadd_filter('excerpt_length', 'twpp_change_excerpt_length', 999);\r\n<\/pre>\n<h2>\u8a18\u4e8b\u4e00\u89a7\u30da\u30fc\u30b8\u30e3\u30fc\u306e\u8a18\u8ff0\u65b9\u6cd5<\/h2>\n<p>\u8a18\u4e8b\u4e00\u89a7\u3067\u306e\u756a\u53f7\u4ed8\u30da\u30fc\u30b8\u30e3\u30fc<br \/>\npaginate_links\u95a2\u6570\u3092\u4f7f\u3063\u305f\u8a18\u8ff0\u3092\u4f7f\u3044\u307e\u3059\u3002<br \/>\n<span class=\"caution\">\u6ce8\u610f\u70b9<\/span><br \/>\n\u203b\u5fc5\u305a\u7ba1\u7406\u753b\u9762\u5185\u306e\u8868\u793a\u4ef6\u6570\u3068\u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8ff0\u3057\u305fposts_per_page\u306e\u8868\u793a\u4ef6\u6570\u3092\u540c\u3058\u306b\u3059\u308b\u3053\u3068<br \/>\n(\u30da\u30fc\u30b8\u9001\u308a\u304c\u3046\u307e\u304f\u3044\u304b\u306a\u3044\u3002)<br \/>\n<a href=\"https:\/\/mahoroba148.com\/page_404er\/\">\u53c2\u8003\u30b5\u30a4\u30c8<\/a><\/p>\n<pre class=\"brush: php; title: function.php; notranslate\" title=\"function.php\">\r\n\/\/ \u8a18\u4e8b\u4e00\u89a7\u30da\u30fc\u30b8\u30e3\u30fc\r\nif ( ! function_exists('wpex_pagination') ) {\r\n  function wp_pagination() {\r\n    global $wp_query;\r\n    $total = $wp_query-&gt;max_num_pages;\r\n    $big = 999999999; \/\/ need an unlikely integer\r\n    if( $total &gt; 1 )  {\r\n       if( !$current_page = get_query_var('paged') )\r\n         $current_page = 1;\r\n       if( get_option('permalink_structure') ) {\r\n         $format = 'page\/%#%\/';\r\n       } else {\r\n         $format = '&amp;paged=%#%';\r\n       }\r\n      echo paginate_links(array(\r\n        'base'    =&gt; str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),\r\n        'format'  =&gt; $format,\r\n        'current' =&gt; max( 1, get_query_var('paged') ),\r\n        'total'   =&gt; $total,\r\n        'mid_size'  =&gt; 4,\r\n        'type'    =&gt; 'list',\r\n        'prev_text' =&gt; '&lt;i class=&quot;fa fa-angle-left&quot;&gt;&lt;\/i&gt;',\r\n        'next_text' =&gt; '&lt;i class=&quot;fa fa-angle-right&quot;&gt;&lt;\/i&gt;',\r\n       ));\r\n    }\r\n  }\r\n}\r\n\r\n\/\/ \u8868\u793a\u3057\u305f\u3044\u30d5\u30a1\u30a4\u30eb\u306b\u4ee5\u4e0b\u306e\u95a2\u6570\u3092\u8a18\u8ff0\r\n&lt;?php wp_pagination(); ?&gt;\r\n<\/pre>\n<p><a href=\"https:\/\/wpdocs.osdn.jp\/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9\/paginate_links\">paginate_links\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a><\/p>\n<h2>\u30ab\u30b9\u30bf\u30e0\u6295\u7a3f\u540d\u3092\u51fa\u529b<\/h2>\n<p>\u4ee5\u4e0b\u306e\u8a18\u8ff0\u3067\u51fa\u529b<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php echo esc_html(get_post_type_object(get_post_type())-&gt;label); ?&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30ef\u30fc\u30c9\u30d7\u30ec\u30b9\u3067\u6a29\u9650\u8005\u3054\u3068\u306b\u7279\u5b9a&hellip;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=\/wp\/v2\/posts\/481"}],"collection":[{"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=481"}],"version-history":[{"count":15,"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=\/wp\/v2\/posts\/481\/revisions"}],"predecessor-version":[{"id":766,"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=\/wp\/v2\/posts\/481\/revisions\/766"}],"wp:attachment":[{"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/memo.baseline-lib.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}