<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>OK &#8211; bhzhuOS爱好者(原StartOS爱好者)</title>
	<atom:link href="https://www.bhzhu203.com/tag/ok/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.bhzhu203.com</link>
	<description>QQ群号125732839</description>
	<lastBuildDate>Thu, 28 Apr 2016 08:14:36 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.7</generator>
	<item>
		<title>wordpress支持相对路径</title>
		<link>https://www.bhzhu203.com/2016/04/28/wordpress%e6%94%af%e6%8c%81%e7%9b%b8%e5%af%b9%e8%b7%af%e5%be%84/</link>
		
		<dc:creator><![CDATA[bhzhu203]]></dc:creator>
		<pubDate>Thu, 28 Apr 2016 08:14:36 +0000</pubDate>
				<category><![CDATA[工作笔记]]></category>
		<category><![CDATA[GUID]]></category>
		<category><![CDATA[OK]]></category>
		<category><![CDATA[URL]]></category>
		<guid isPermaLink="false">http://www.bhzhu203.com/?p=235</guid>

					<description><![CDATA[1、修改wp-config.php文件 &#60;?php $home = ‘ht [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>1、修改wp-config.php文件</p>
<p>&lt;?php<br />
$home = ‘http://’.$_SERVER[&#8216;HTTP_HOST&#8217;];<br />
$siteurl = ‘http://’.$_SERVER[&#8216;HTTP_HOST&#8217;];<br />
define(‘WP_HOME’, $home);<br />
define(‘WP_SITEURL’, $siteurl);<br />
?&gt;</p>
<p>这样修改后，在后台的 setting-options 页面，只能显示而不能修改home和siteurl两个值（因为它们已经被定义成两个常量了，呵呵），它们完全是根据访问域名显示的。</p>
<p>2、修改多媒体插件<br />
更改多媒体插件插入图片时使用相对路径！<br />
另外两种方式如下：<br />
1.修改wordpress根目录下的wp-config.php，在该文件中加入一下两行</p>
<p>define(‘WP_HOME’, ”);<br />
define(‘WP_SITEURL’, ”);</p>
<p>保存，OK了！但是这种修改方式是只能用户网网站根目录，并且使用默认的80端口。<br />
如果你不是用网站的根目录，或者用非80端口，那就用第二种方法：<br />
2.打开wp-includes/post.php文件，修改函数wp_get_attachment_url为如下代码：</p>
<p>/**<br />
* Retrieve the URL for an attachment.<br />
*<br />
* @since 2.1.0<br />
*<br />
* @param int $post_id Attachment ID.<br />
* @return string<br />
*/<br />
function wp_get_attachment_url( $post_id = 0 ) {<br />
$file_dir=dirname(__FILE__);<br />
$server_root=$_SERVER[DOCUMENT_ROOT];<br />
$file_dir=substr($file_dir,strlen($server_root));<br />
$file_dir=substr($file_dir,0,-12);<br />
if($file_dir!=”){<br />
$file_dir=&#8217;/&#8217;.substr($file_dir,1);<br />
}<br />
$post_id = (int) $post_id;<br />
if ( !$post = get_post( $post_id ) )<br />
return false;</p>
<p>if ( &#8216;attachment&#8217; != $post-&gt;post_type )<br />
return false;</p>
<p>$url = &#8221;;<br />
if ( $file = get_post_meta( $post-&gt;ID, &#8216;_wp_attached_file&#8217;, true) ) { //Get attached file<br />
if ( ($uploads = wp_upload_dir()) &amp;&amp; false === $uploads[&#8216;error&#8217;] ) { //Get upload directory<br />
if ( 0 === strpos($file, $uploads[&#8216;basedir&#8217;]) ) //Check that the upload base exists in the file location<br />
//$url = str_replace($uploads[&#8216;basedir&#8217;], $uploads[&#8216;baseurl&#8217;], $file); //replace file location with url location<br />
$url=$file_dir.&#8217;/wp-content/uploads/&#8217;.$file;<br />
elseif ( false !== strpos($file, &#8216;wp-content/uploads&#8217;) )<br />
//$url = $uploads[&#8216;baseurl&#8217;] . substr( $file, strpos($file, &#8216;wp-content/uploads&#8217;) + 18 );<br />
$url=$file_dir.&#8217;/wp-content/uploads/&#8217;.$file;<br />
else<br />
//$url = $uploads[&#8216;baseurl&#8217;] . &#8220;/$file&#8221;; //Its a newly uploaded file, therefor $file is relative to the basedir.<br />
$url=$file_dir.&#8217;/wp-content/uploads/&#8217;.$file;<br />
}<br />
}</p>
<p>if ( empty($url) ) //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recommended to rely upon this.<br />
$url = get_the_guid( $post-&gt;ID );</p>
<p>/**<br />
* Filter the attachment URL.<br />
*<br />
* @since 2.1.0<br />
*<br />
* @param string $url URL for the given attachment.<br />
* @param int $post_id Attachment ID.<br />
*/<br />
$url = apply_filters( &#8216;wp_get_attachment_url&#8217;, $url, $post-&gt;ID );</p>
<p>if ( empty( $url ) )<br />
return false;</p>
<p>return $url;<br />
}</p>
<p>原文地址：http://blog.zhu-hai.com/web/38.html</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
