{"id":4958,"date":"2025-04-21T15:54:43","date_gmt":"2025-04-21T14:54:43","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=4958"},"modified":"2025-05-06T16:47:39","modified_gmt":"2025-05-06T15:47:39","slug":"wordpress-install-sub-folder","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/pages-wordpress\/wordpress-install-sub-folder","title":{"rendered":"WordPress install sub folder"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Getting the sub folder install location for WordPress if its not installed in the site root<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Simple home_url() method<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  wp_redirect( home_url( '\/' ) );\n  \/\/wp_redirect( home_url( '\/my_page_name' ) );    \/\/If you want to redirect to a specific page\n  die();<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Getting it in code<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  \/\/Get WordPress sub folder path if its not instlaled on the site root\n  $SiteUrl = get_site_url();\n  $ParsedUrl = parse_url($SiteUrl);\n  $WordpressInstallSubPath = trim($ParsedUrl&#91;'path'] ?? '', '\/');   \/\/Trim leading\/trailing slashes and return full path (if any)\n  if (strlen($WordpressInstallSubPath) &gt; 0)\n    $WordpressInstallSubPath = '\/' . $WordpressInstallSubPath;   \n  \/\/Install URL                       $WordpressInstallSubPath\n  \/\/https:\/\/example.com\t              '' (empty \u2014 root)\n  \/\/https:\/\/example.com\/wordpress\t    '\/wordpress'\n  \/\/https:\/\/example.com\/blog\/wp\t      '\/blog\/wp'\n  \/\/https:\/\/example.com\/a\/b\/c\t        '\/a\/b\/c'<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Getting the sub folder install location for WordPress if its not installed in the site root Simple home_url() method Getting it in code<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[120,302],"tags":[],"class_list":["post-4958","post","type-post","status-publish","format-standard","hentry","category-pages-wordpress","category-site"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=4958"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4958\/revisions"}],"predecessor-version":[{"id":4973,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4958\/revisions\/4973"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=4958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=4958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=4958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}