{"id":3995,"date":"2020-11-02T21:17:36","date_gmt":"2020-11-02T12:17:36","guid":{"rendered":"http:\/\/dubdesign.net\/?p=3995"},"modified":"2020-11-03T10:14:37","modified_gmt":"2020-11-03T01:14:37","slug":"shortcode-php","status":"publish","type":"post","link":"https:\/\/dubdesign.net\/web\/wordpress\/shortcode-php\/","title":{"rendered":"\u30d7\u30e9\u30b0\u30a4\u30f3\u306a\u3057\u3067\u30da\u30fc\u30b8\u5185\u306bPHP\u3092\u8aad\u307f\u8fbc\u3080\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3067php\u3092\u8a18\u8ff0\u3067\u304d\u308b\u4ed5\u69d8\u306b\u3059\u308b\u3053\u3068\u3067\u3001\u56fa\u5b9a\u30da\u30fc\u30b8\u3084\u6295\u7a3f\u30da\u30fc\u30b8\u3001\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3001\u30e1\u30cb\u30e5\u30fc\u306a\u3069\u3001Wordpress\u5185\u306e\u597d\u304d\u306a\u5834\u6240\u306bphp\u3092\u8a2d\u7f6e\u3059\u308b\u4e8b\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306a\u3057\u3067\u30da\u30fc\u30b8\u5185\u306bphp\u3092\u8aad\u307f\u8fbc\u3080\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#i\">\u5168\u4f53\u7684\u306a\u6d41\u308c<\/a><\/li><li><a href=\"#functionsphp\">functions.php\u306b\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0<\/a><ul><li><a href=\"#i-2\">\u89aa\u30c6\u30fc\u30de\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u5834\u5408<\/a><\/li><li><a href=\"#i-3\">\u5b50\u30c6\u30fc\u30de\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u5834\u5408<\/a><\/li><\/ul><\/li><li><a href=\"#php\">\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u306ephp\u3092\u4f5c\u308b<\/a><\/li><li><a href=\"#i-4\">\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u4efb\u610f\u306e\u5834\u6240\u306b\u8a18\u8ff0<\/a><\/li><\/ul><\/div>\n<h2><span id=\"i\">\u5168\u4f53\u7684\u306a\u6d41\u308c<\/span><\/h2>\n\n\n\n<p>\u3053\u306e\u5b9f\u88c5\u306f3\u3064\u306eSTEP\u3067\u5b9f\u88c5\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"tl\">\n<div class=\"tl-content main-bdr\"><div class=\"tl_label\">STEP.1<\/div><div class=\"tl_title\">functions.php\u306b\u30b3\u30d4\u30da<\/div><div class=\"tl_main\"> \u5916\u89b3 \uff1e \u30c6\u30fc\u30de\u30a8\u30c7\u30a3\u30bf\u30fc\u306e\u300c\u30c6\u30fc\u30de\u306e\u305f\u3081\u306e\u95a2\u6570 (functions.php)\u300d\u306b\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30da<br><img src=\"https:\/\/dubdesign.net\/wp-content\/uploads\/2020\/05\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2020-05-30-17.03.38.jpg\"> <\/div><div class=\"tl_marker main-bdr main-bc\"><\/div><\/div>\n<div class=\"tl-content main-bdr\"><div class=\"tl_label\">STEP.2<\/div><div class=\"tl_title\">\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u306ephp\u3092\u4f5c\u308b<\/div><div class=\"tl_main\"> function.php\u306e\u540c\u968e\u5c64\u306b\u3067\u8868\u793a\u3059\u308b\u3088\u3046php\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u3001\u6709\u52b9\u5316\u3057\u305f\u30c6\u30fc\u30de\u3068\u540c\u3058\u968e\u5c64\u306b\u8a2d\u7f6e\u3057\u307e\u3059\u3002<img src=\"https:\/\/dubdesign.net\/wp-content\/uploads\/2020\/11\/phpmake_step02.jpg\"> <\/div><div class=\"tl_marker main-bdr main-bc\"><\/div><\/div>\n<div class=\"tl-content main-bdr\"><div class=\"tl_label\">STEP.3<\/div><div class=\"tl_title\">\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u4efb\u610f\u306e\u5834\u6240\u306b\u8a18\u8ff0<\/div><div class=\"tl_main\"> \u30b5\u30f3\u30d7\u30ebphp\u3092\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u4f7f\u3044\u3001\u547c\u3073\u51fa\u3059\u70ba\u4efb\u610f\u306e\u5834\u6240\u306b\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3057\u307e\u3057\u3087\u3046\u3002 <\/div><div class=\"tl_marker main-bdr main-bc\"><\/div><\/div>\n<\/div>\n\n\n\n<div class=\"memo alert\"><div class=\"memo_ttl dfont\"> \u6ce8\u610f<\/div>functions.php\u3092\u3044\u3058\u308b\u5834\u5408\u3001ftp\u3067\u5fc5\u305a\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3092\u53d6\u3063\u3066\u304b\u3089\u884c\u3044\u3001\u30c6\u30fc\u30de\u672c\u4f53\u3067\u306f\u306a\u304f\u5b50\u30c6\u30fc\u30de\u306e\u65b9\u306b\u95a2\u6570\u3092\u30b3\u30d4\u30da\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/div>\n\n\n\n<h2><span id=\"functionsphp\">functions.php\u306b\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0<\/span><\/h2>\n\n\n\n<p>functions.php\u306e\u5834\u6240\u306f\u300cWordPress\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u5834\u6240\u300d\u2192\u300cwp-content\u300d\u2192\u300cthemes\u300d\u2192\u300c\u6709\u52b9\u5316\u4e2d\u306e\u30c6\u30fc\u30de\u300d\u306e\u4e2d\u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u89aa\u30c6\u30fc\u30de\u3001\u5b50\u30c6\u30fc\u30de\u306e\u69cb\u9020\u306f\u305d\u308c\u305e\u308c\u4f7f\u7528\u3057\u3066\u3044\u308b\u30c6\u30fc\u30de\u3067\u7570\u306a\u308a\u307e\u3059\u304c\u3001<code>functions.php<\/code>\u306b\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u8cbc\u308a\u4ed8\u3051\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3><span id=\"i-2\">\u89aa\u30c6\u30fc\u30de\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u5834\u5408<\/span><\/h3>\n\n\n\n<div class=\"htmlcodebox\">\n    <span class=\"box-title\">function.php<\/span>\n    <p><pre><code>\/* \u89aa\u30c6\u30fc\u30de\u968e\u5c64\u306ePHP\u306e\u8aad\u307f\u8fbc\u307f\n---------------------------------------------------------- *\/\nfunction short_php($params = array()) {\n  extract(shortcode_atts(array(\n    &#039;file&#039; =&gt; &#039;default&#039;\n  ), $params));\n  ob_start();\n  include(get_theme_root() . &#039;\/&#039; . get_template() . &quot;\/$file.php&quot;);\n  return ob_get_clean();\n}\n \nadd_shortcode(&#039;call_php&#039;, &#039;my_php_Include&#039;);<\/code><\/pre><\/p>\n<\/div>\n\n\n\n<h3><span id=\"i-3\">\u5b50\u30c6\u30fc\u30de\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u5834\u5408<\/span><\/h3>\n\n\n\n<div class=\"htmlcodebox\">\n    <span class=\"box-title\">function.php<\/span>\n    <p><pre><code>\/* PHP\u306e\u8aad\u307f\u8fbc\u307f\n---------------------------------------------------------- *\/\nfunction my_php_Include($params = array()) {\nextract(shortcode_atts(array(&#039;file&#039; =&gt; &#039;default&#039;), $params));\nob_start();\ninclude(STYLESHEETPATH . &quot;\/$file.php&quot;);\nreturn ob_get_clean();\n}\nadd_shortcode(&#039;call_php&#039;, &#039;my_php_Include&#039;);<\/code><\/pre><\/p>\n<\/div>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3092\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3067\u3001functions.php\u3068\u540c\u3058\u968e\u5c64\u306b\u3042\u308bphp\u306e\u30c7\u30fc\u30bf\u3092\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2><span id=\"php\">\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u306ephp\u3092\u4f5c\u308b<\/span><\/h2>\n\n\n\n<p>function.php\u306e\u540c\u968e\u5c64\u306b\u3067\u8868\u793a\u3059\u308b\u3088\u3046php\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u306a\u3093\u3067\u3082\u826f\u304f\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u306b\u306f\u8868\u793a\u3055\u305b\u305f\u3044\u8a18\u8ff0\u3092\u3057\u3066\u3001function.php\u306e\u540c\u968e\u5c64\u306b\u3067\u304d\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u8a2d\u7f6e\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>function.php\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u968e\u5c64\u306f\u3001\u300cWordPress\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u5834\u6240\u300d\u2192\u300cwp-content\u300d\u2192\u300cthemes\u300d\u2192\u300c\u6709\u52b9\u5316\u4e2d\u306e\u30c6\u30fc\u30de\u300d\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"944\" height=\"428\" src=\"https:\/\/dubdesign.net\/wp-content\/uploads\/2020\/11\/phpmake_step02.jpg\" alt=\"ftp\u306e\u30d5\u30a1\u30a4\u30eb\u30b5\u30fc\u30d0\u30fc\" class=\"wp-image-4006\" srcset=\"https:\/\/dubdesign.net\/wp-content\/uploads\/2020\/11\/phpmake_step02.jpg 944w, https:\/\/dubdesign.net\/wp-content\/uploads\/2020\/11\/phpmake_step02-300x136.jpg 300w, https:\/\/dubdesign.net\/wp-content\/uploads\/2020\/11\/phpmake_step02-768x348.jpg 768w, https:\/\/dubdesign.net\/wp-content\/uploads\/2020\/11\/phpmake_step02-940x426.jpg 940w\" sizes=\"(max-width: 944px) 100vw, 944px\" \/><\/figure>\n\n\n\n<h2><span id=\"i-4\">\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u4efb\u610f\u306e\u5834\u6240\u306b\u8a18\u8ff0<\/span><\/h2>\n\n\n\n<p>\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\u30b5\u30f3\u30d7\u30ebphp\u3092\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u4f7f\u3044\u3001\u547c\u3073\u51fa\u3059\u70ba\u4efb\u610f\u306e\u5834\u6240\u306b\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30fc\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<div class=\"htmlcodebox\">\n    <span class=\"box-title\">\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9<\/span>\n    <p><pre><code>[call_php file=&#039;\u25cf\u25cf\u25cf\u25cf\u25cf&#039;]<\/code><\/pre><\/p>\n<\/div>\n\n\n\n<p>\u300cfile=\u2019\u25cf\u25cf\u25cf\u25cf\u25cf\u2019\u300d\u306b\u4fdd\u5b58\u3057\u305fphp\u306e\u540d\u524d\u3092\u66f8\u304d\u8fbc\u3081\u3070\u3001\u305d\u306ePHP\u3092\u547c\u3073\u51fa\u3057\u3066\u8868\u793a\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u540d\u524d\u306f\u62e1\u5f35\u5b50\u304c\u4e0d\u8981\u306a\u306e\u3067\u300c.php\u300d\u3092\u629c\u3044\u305f\u3082\u306e\u3067\u3001\u4f8b\u3067\u300c<strong>sample<\/strong>.php\u300d\u306e\u5834\u5408\u306f\u3001\u300ccall_php file=\u2019<strong>sample<\/strong>\u2018\u300d\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u3001\u672c\u6765php\u3092\u547c\u3073\u51fa\u305b\u306a\u3044\u3001\u6295\u7a3f\u8a18\u4e8b\u3084\u56fa\u5b9a\u30da\u30fc\u30b8\u3001\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u306b\u3082php\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"hh hh26\">\u53c2\u8003\u30b5\u30a4\u30c8<\/p>\n\n\n\n  <a class=\"reference table\" href=\"http:\/\/vdeep.net\/wp-php-in-article\" target=\"_blank\" rel=\"noopener noreferrer\">\n    <span class=\"tbcell refttl\">\u53c2\u8003<\/span>\n    <span class=\"tbcell refcite\">WordPress\u6295\u7a3f\u30da\u30fc\u30b8\u306bPHP\u5229\u7528\u2192\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u4f7f\u304a\u3046\uff01<span>vdeep<\/span><\/span>\n  <\/a>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3067php\u3092\u8a18\u8ff0\u3067\u304d\u308b\u4ed5\u69d8\u306b\u3059\u308b\u3053\u3068\u3067\u3001\u56fa\u5b9a\u30da\u30fc\u30b8\u3084\u6295\u7a3f\u30da\u30fc\u30b8\u3001\u30a6\u30a3\u30b8\u30a7\u30c3\u30c8\u3001\u30e1\u30cb\u30e5\u30fc\u306a\u3069\u3001Wordpress\u5185\u306e\u597d\u304d\u306a\u5834\u6240\u306bphp\u3092\u8a2d\u7f6e\u3059\u308b\u4e8b\u304c\u3067\u304d\u307e\u3059\u3002 \u4eca\u56de\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306a\u3057\u3067\u30da\u30fc\u30b8\u5185\u306bphp\u3092\u8aad\u307f\u8fbc\u3080 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":4015,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[60],"tags":[62,61],"acf":[],"_links":{"self":[{"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/posts\/3995"}],"collection":[{"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/comments?post=3995"}],"version-history":[{"count":18,"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/posts\/3995\/revisions"}],"predecessor-version":[{"id":4030,"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/posts\/3995\/revisions\/4030"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/media\/4015"}],"wp:attachment":[{"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/media?parent=3995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/categories?post=3995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dubdesign.net\/wp-json\/wp\/v2\/tags?post=3995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}