<?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>运达&#039;s  blog &#187; WordPress</title>
	<atom:link href="https://www.yunda51.com/?cat=11&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>https://www.yunda51.com</link>
	<description>运达的博客</description>
	<lastBuildDate>Wed, 12 Nov 2025 07:58:26 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.19</generator>
	<item>
		<title>WordPress添加相关文章功能（标题/缩略图样式）</title>
		<link>https://www.yunda51.com/?p=1661</link>
		<comments>https://www.yunda51.com/?p=1661#comments</comments>
		<pubDate>Thu, 31 Dec 2015 02:15:59 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[相关文章]]></category>
		<category><![CDATA[缩略图]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1661</guid>
		<description><![CDATA[直接上代码： 1.添加含缩略图的相关文章 如图： 首先1)在主题的 functions.php 的最后一个 ?<a href="https://www.yunda51.com/?p=1661" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>直接上代码：<br />
<strong>1.添加含缩略图的相关文章</strong><br />
如图：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2015/12/109.png"><img class="alignnone size-full wp-image-1662" src="http://www.yunda51.com/wp-content/uploads/2015/12/109.png" alt="109" width="578" height="200" /></a><br />
<strong>首先1)在主题的 functions.php 的最后一个 ?> 前添加下面的代码：</strong></p>
<pre class="wp-code-highlight prettyprint">
    //添加特色缩略图支持

    if ( function_exists(&#039;add_theme_support&#039;) )add_theme_support(&#039;post-thumbnails&#039;);

     

    //输出缩略图地址 From wpdaxue.com

    function post_thumbnail_src(){
        global $post;
    	if( $values = get_post_custom_values(&quot;thumb&quot;) ) {	//输出自定义域图片地址
    		$values = get_post_custom_values(&quot;thumb&quot;);
    		$post_thumbnail_src = $values [0];
    	} elseif( has_post_thumbnail() ){    //如果有特色缩略图，则输出缩略图地址
            $thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post-&gt;ID),&#039;full&#039;);
    		$post_thumbnail_src = $thumbnail_src [0];
        } else {
    		$post_thumbnail_src = &#039;&#039;;
    		ob_start();
    		ob_end_clean();
    		$output = preg_match_all(&#039;/&lt;img.+src=[\&#039;&quot;]([^\&#039;&quot;]+)[\&#039;&quot;].*&gt;/i&#039;, $post-&gt;post_content, $matches);
    		$post_thumbnail_src = $matches [1] [0];   //获取该图片 src
    		if(empty($post_thumbnail_src)){	//如果日志中没有图片，则显示随机图片
    			$random = mt_rand(1, 10);
    			echo get_bloginfo(&#039;template_url&#039;);
    			echo &#039;/images/pic/&#039;.$random.&#039;.jpg&#039;;
    			//如果日志中没有图片，则显示默认图片
    			//echo &#039;/images/default_thumb.jpg&#039;;
    		}
    	};
    	echo $post_thumbnail_src;
    }
</pre>
<p>PS：上面的代码主要是获取图片链接，获取的顺序是：</p>
<p>自定义字段为 thumb 的图片>特色缩略图>文章第一张图片>随机图片/默认图片；</p>
<p>随机图片：请制作10张图片，放在现用主题文件夹下的 images/pic/ 目录，图片为jpg格式，并且使用数字 1-10命名，比如 1.jpg；如果你不想用随机图片，请将 倒数第5行 前面的“//”去掉，然后给 倒数第7、9行 前面添加“//”注销，并且在现用主题的 /images/ 目录下添加一张名字为 default_thumb.jpg 的默认图片，这样，就会显示默认图片。</p>
<p><strong>2)将下面的代码添加到 single.php 要显示相关文章的位置：</strong></p>
<pre class="wp-code-highlight prettyprint">
    &lt;h3&gt;相关文章&lt;/h3&gt;

    &lt;ul class=&quot;related_img&quot;&gt;

    &lt;?php
    $post_num = 4;
    $exclude_id = $post-&gt;ID;
    $posttags = get_the_tags(); $i = 0;
    if ( $posttags ) {
    	$tags = &#039;&#039;; foreach ( $posttags as $tag ) $tags .= $tag-&gt;term_id . &#039;,&#039;;
    	$args = array(
    		&#039;post_status&#039; =&gt; &#039;publish&#039;,
    		&#039;tag__in&#039; =&gt; explode(&#039;,&#039;, $tags),
    		&#039;post__not_in&#039; =&gt; explode(&#039;,&#039;, $exclude_id),
    		&#039;caller_get_posts&#039; =&gt; 1,
    		&#039;orderby&#039; =&gt; &#039;comment_date&#039;,
    		&#039;posts_per_page&#039; =&gt; $post_num
    	);

    	query_posts($args);
    	while( have_posts() ) { the_post(); ?&gt;
    		&lt;li class=&quot;related_box&quot;  &gt;
    		&lt;div class=&quot;r_pic&quot;&gt;
    		&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot; target=&quot;_blank&quot;&gt;
    		&lt;img src=&quot;&lt;?php echo post_thumbnail_src(); ?&gt;&quot; alt=&quot;&lt;?php the_title(); ?&gt;&quot; class=&quot;thumbnail&quot; /&gt;
    		&lt;/a&gt;
    		&lt;/div&gt;
    		&lt;div class=&quot;r_title&quot;&gt;&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot; target=&quot;_blank&quot; rel=&quot;bookmark&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/div&gt;
    		&lt;/li&gt;
    	&lt;?php
    		$exclude_id .= &#039;,&#039; . $post-&gt;ID; $i ++;
    	} wp_reset_query();
    }

    if ( $i &lt; $post_num ) {

    	$cats = &#039;&#039;; foreach ( get_the_category() as $cat ) $cats .= $cat-&gt;cat_ID . &#039;,&#039;;
    	$args = array(
    		&#039;category__in&#039; =&gt; explode(&#039;,&#039;, $cats),
    		&#039;post__not_in&#039; =&gt; explode(&#039;,&#039;, $exclude_id),
    		&#039;caller_get_posts&#039; =&gt; 1,
    		&#039;orderby&#039; =&gt; &#039;comment_date&#039;,
    		&#039;posts_per_page&#039; =&gt; $post_num - $i
    	);
    	query_posts($args);
    	while( have_posts() ) { the_post(); ?&gt;
    	&lt;li class=&quot;related_box&quot;  &gt;
    		&lt;div class=&quot;r_pic&quot;&gt;
    		&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot; target=&quot;_blank&quot;&gt;
    		&lt;img src=&quot;&lt;?php echo post_thumbnail_src(); ?&gt;&quot; alt=&quot;&lt;?php the_title(); ?&gt;&quot; class=&quot;thumbnail&quot; /&gt;
    		&lt;/a&gt;
    		&lt;/div&gt;
    		&lt;div class=&quot;r_title&quot;&gt;&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot; target=&quot;_blank&quot; rel=&quot;bookmark&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/div&gt;
    	&lt;/li&gt;
    	&lt;?php $i++;
    	} wp_reset_query();
    }
    if ( $i  == 0 )  echo &#039;&lt;div class=&quot;r_title&quot;&gt;没有相关文章!&lt;/div&gt;&#039;;
    ?&gt;
    &lt;/ul&gt;
</pre>
<p>PS：第四行$post_num = 4; 表示调用4篇文章，请根据自己需要修改。</p>
<p>css样式自己写，也可参考一下：</p>
<pre class="wp-code-highlight prettyprint">
    .related_posts{margin-top:5px;}
    .related_img{width:600px;height:210px;}
    .related_box{float:left;overflow:hidden;margin-top:5px;width:148px;border-right:1px #eee solid}
    .related_box:hover{background:#f9f9f9}
    .related_box .r_title{width:auto;height:72px;font-weight:400;font-size:14px;margin:0 10px;overflow:hidden;}
    .related_box .r_pic{margin:6px}
    .related_box .r_pic img{width:130px;height:100px;border:1px  solid #e1e1e1;background:#fff;padding:2px}
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1661</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Google Fonts导致WordPress 速度问题</title>
		<link>https://www.yunda51.com/?p=1337</link>
		<comments>https://www.yunda51.com/?p=1337#comments</comments>
		<pubDate>Fri, 20 Jun 2014 10:59:32 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Google Fonts]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1337</guid>
		<description><![CDATA[最近下载的wordpress3.9版本,安装之后特别慢,最后发现是Google Fonts导致的,真让人蛋疼.<a href="https://www.yunda51.com/?p=1337" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>最近下载的wordpress3.9版本,安装之后特别慢,最后发现是Google Fonts导致的,真让人蛋疼.<br />
<strong>Google Fonts导致WordPress 速度问题之原因</strong><br />
WordPress 自3.8+版本后加入了Google Fonts（别问我Google Fonts是什么了），然后捏，因为近期敏感周期（35号），天朝发威，谷歌的一系列网站被彻底墙，包括Google Fonts 所在的googleapis.com 。所以，如果是在登陆状态下打开你的WordPress 站点，会非常慢，因为压根儿加载不了这个字体文件。如果是非登陆状态且你的主题不是老外的主题，一般来说都是正常的。</p>
<p><strong>解决方法</strong><br />
出来问题就要解决，在天朝，既然你不得不忍受之，那么就换个思路变通一下。下面的解决方法，思路一是禁止加载该Google Fonts，二是替换加载源。下面说明之：</p>
<p><strong>方法一：</strong>【插件】禁止WordPress 后台加载Google Fonts</p>
<p>安装启用 Disable Google Fonts 或者 Remove Open Sans font Link from WP core 其中之一即可。没啥好说的。</p>
<p><strong>方法二：</strong>【代码】直接在functions.php 文件添加代码</p>
<p>网络上有不少代码，下面可以参考下，具体有没有效果没有确认：</p>
<pre class="wp-code-highlight prettyprint">
add_filter(&#039;gettext_with_context&#039;, &#039;disable_open_sans&#039;, 888, 4 );
      function disable_open_sans( $translations, $text, $context, $domain ){
             if ( &#039;Open Sans font: on or off&#039; == $context &amp;&amp; &#039;on&#039; == $text ) {
             $translations = &#039;off&#039;;}return $translations;} 
      function dw_remove_open_sans() {      
            wp_deregister_style( &#039;open-sans&#039; );          
            wp_register_style( &#039;open-sans&#039;, false );         
            wp_enqueue_style(&#039;open-sans&#039;,&#039;&#039;);      } 
            add_action( &#039;init&#039;, &#039;dw_remove_open_sans&#039; );
</pre>
<p>方法三：【代码】替换open sans 字体的加载源</p>
<p>打开wordpress代码中的文件wp-includes/script-loader.php文件，搜索：fonts.googleapis.com 找到这行代码：</p>
<p>$open_sans_font_url = "//fonts.googleapis.com/css?family1=Open+Sans:300italic,400italic,600italic,300,400,600&#038;subset=$subsets";</p>
<p>把fonts.googleapis.com替换为fonts.useso.com。<br />
转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1337.html">http://www.yunda51.com/1337.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1337</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WordPress后台更新和插件更新“需要访问您网页服务器的权限”的问题</title>
		<link>https://www.yunda51.com/?p=1289</link>
		<comments>https://www.yunda51.com/?p=1289#comments</comments>
		<pubDate>Mon, 05 May 2014 07:06:57 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1289</guid>
		<description><![CDATA[最近网站搬家从windows上搬到liunx服务器上,wordpress网站后台,在安装主题（或者升级系统，插<a href="https://www.yunda51.com/?p=1289" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>最近网站搬家从windows上搬到liunx服务器上,wordpress网站后台,在安装主题（或者升级系统，插件）时，提示：“要执行请求的操作，WordPress需要访问您网页服务器的权限。 请输入您的FTP登录凭据以继续。 如果您忘记了您的登录凭据（如用户名、密码），请联系您的网站托管商。” 如图：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2014/05/ftp.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2014/05/ftp.jpg" alt="" title="ftp" width="1366" height="634" class="alignnone size-full wp-image-1290" /></a><br />
解决方法</p>
<p>方法一：</p>
<p>如果我们安装的是lamp一键安装包，那可以使用。授权组来解决。</p>
<p>#chown -R www   /usr/share/nginx/html     ##(修改成网站域名目录)</p>
<p>#chmod  -R 777 /usr/share/nginx/html</p>
<p>方法二：</p>
<p>如果是其他的可以使用在wp-config.php文件中添加脚本方式。</p>
<p>define("FS_METHOD","direct");</p>
<p>define("FS_CHMOD_DIR", 0777);</p>
<p>define("FS_CHMOD_FILE", 0777);</p>
<p>把以上代码添加到wp.config.php里面即可!</p>
<p>如果下载插件失败可以在wp.config.php里加上如下代码: define('WP_TEMP_DIR', ABSPATH . 'wp-content/plugins');<br />
<strong>如图所示:</strong><br />
<a href="http://www.yunda51.com/wp-content/uploads/2014/05/120819.jpg"><img src="http://www.yunda51.com/wp-content/uploads/2014/05/120819.jpg" alt="" title="120819" width="605" height="231" class="alignnone size-full wp-image-1335" /></a><br />
其实这两个方法都是通用的，不存在哪个好与坏~~<br />
转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/1289.html">http://www.yunda51.com/1289.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1289</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何实现wordpress二级分类目录（页面）导航</title>
		<link>https://www.yunda51.com/?p=875</link>
		<comments>https://www.yunda51.com/?p=875#comments</comments>
		<pubDate>Wed, 17 Apr 2013 08:55:24 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=875</guid>
		<description><![CDATA[最近用wp做网站，发现一个问题，大部分主题都可以在菜单下添加二级分类目录页面导航，但是有的主题即使在菜单下添加<a href="https://www.yunda51.com/?p=875" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>最近用wp做网站，发现一个问题，大部分主题都可以在菜单下添加二级分类目录页面导航，但是有的主题即使在菜单下添加添加了，仍然在前台页面也无法显示二级目录，那么就需要咱们去想办法解决了，实现这个功能要用到两个函数。<br />
<strong>首先应该把如下代码放到header.php里面：</strong></p>
<div class="buy shortcodestyle">
&lt;!--添加显示二级导航菜单--&gt;<br />
&lt;!-- 页面导航菜单 START --&gt;<br />
&lt;!--&lt;div id="menu"&gt;<br />
&lt;div class="menub"&gt;<br />
&lt;ul&gt;<br />
&lt;li&lt;?php if (is_home()) { echo ' class="current-cat"';} ?&gt;&gt;&lt;a title="&lt;?php _e('Home', 'default'); ?&gt;" href="&lt;?php echo get_settings('home'); ?&gt;/"&gt;&lt;?php _e('Home', 'default'); ?&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;?php<br />
$currentcategory = '';<br />
// 以下这行代码用于在导航栏添加分类列表，<br />
if (!is_page() &amp;&amp; !is_home()) {<br />
$catsy = get_the_category();<br />
$myCat = $catsy[0]-&gt;cat_ID;<br />
$currentcategory = '&amp;current_category='.$myCat;<br />
}<br />
wp_list_categories('depth=2&amp;title_li=&amp;show_count=0&amp;hide_empty=0'.$currentcategory);</p>
<p>// 以下这行代码用于在导航栏添加页面列表<br />
wp_list_pages('depth=2&amp;title_li=&amp;sort_column=menu_order');<br />
?&gt;<br />
&lt;/ul&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;--&gt;<br />
&lt;!-- 页面导航菜单 END --&gt;
</p></div>
<p><strong>然后就是CSS来设置这个menub了</strong></p>
<div class="buy shortcodestyle">
/*菜单导航二级目录*/<br />
#menu{width:960px;margin:10px auto 0px;border:1px #aaa;-webkit-box-shadow:#ccc 0 0 5px;-moz-box-shadow:#CCC 0 0 5px;box-shadow:#CCC 0 0 5px;background:#FFF;height:35px}  </p>
<p> /*#menu{width:960px;margin:10px auto 0px;border:1px solid #aaa;-webkit-box-shadow:#ccc 0 0 5px;-moz-box-shadow:#CCC 0 0 5px;box-shadow:#CCC 0 0 5px;background:#FFF;height:35px}*/  </p>
<p> #footer{width:960px;margin:30px auto 10px;border:1px solid #aaa;-webkit-box-shadow:#CCC 0 0 5px;-moz-box-shadow:#CCC 0 0 5px;box-shadow:#CCC 0 0 5px;background:#FFF;height:35px}  </p>
<p> #menu ul li,#footer ul li{float:left;text-align:center;min-width:57px}  </p>
<p> #menu ul li a,#footer ul li a{font-size:14px;display:block;padding:7px 14px;white-space:nowrap}  </p>
<p> #menu ul li:hover a,#footer ul li:hover a{transform:rotate(6deg);-webkit-transform:rotate(6deg);-moz-transform:rotate(6deg);-o-transform:rotate(6deg)}  </p>
<p> #menu ul li:hover,#footer ul li:hover{background:#f2f2f2;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}  </p>
<p> #menu ul li.current-cat a,.current_page_item a{color:#1ba1e2}  </p>
<p> .menub{font-size:12px;position:relative;z-index:100;}  </p>
<p> .menub ul{list-style:none;}  </p>
<p> .menub li {float:left;position:relative;}  </p>
<p> .menub ul ul {visibility:hidden;position:absolute;}  </p>
<p> .menub table {position:absolute; top:0; left:0;}  </p>
<p> .menub ul li:hover ul,  </p>
<p> .menub ul a:hover ul{visibility:visible;}  </p>
<p> .menub a{display:block;background:#ffffff;padding:0px;margin:0px;color:#777777;text-decoration:none;}  </p>
<p> .menub a:hover{background:#f2f2f2;color:#f09609;}  </p>
<p> .menub ul ul{}  </p>
<p> .menub ul ul li {clear:both;text-align:left;font-size:12px;}  </p>
<p> .menub ul ul li a{display:block;width:100px;height:13px;margin:0;border-bottom:1px solid #000000;}  </p>
<p> .menub ul ul li a:hover{border:0;background:#bce27f;}
</p></div>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/875.html">http://www.yunda51.com/875.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=875</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>WordPress设置文章页面的动态关键字和描述</title>
		<link>https://www.yunda51.com/?p=758</link>
		<comments>https://www.yunda51.com/?p=758#comments</comments>
		<pubDate>Mon, 14 Jan 2013 16:28:43 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=758</guid>
		<description><![CDATA[闲着没事用Wp给朋友做了个企业站，经过一番苦战网站终于上线了，在添加关键字和描述的时候发现这个主题后台竟然没有<a href="https://www.yunda51.com/?p=758" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>闲着没事用Wp给朋友做了个企业站，经过一番苦战网站终于上线了，在添加关键字和描述的时候发现这个主题后台竟然没有地方添加，添加关键字和描述更利于网站的收录！好吧，只能自己想办法了，于是乎，这篇文章就诞生啦！</p>
<p>其实很简单，如果你设置了网站关键字和描述的话（手动添加），我已经把代码整理好了</p>
<div class="task shortcodestyle"><strong>首先：</strong>打开直接修改源文件（header.php），或者你可以登录后台修改：外观-编辑-选择修改（顶部）header.php文件。<br />
<strong>找到如下代码：</strong><br />
把&lt;meta name="keywords" content="这里是你网站首页的关键字" /&gt;替换为：</p>
<p>&lt;meta name="keywords" content="&lt;?php if (is_single()){ $keywords = "";$tags = wp_get_post_tags($post-&gt;ID);foreach ($tags as $tag ) {$keywords = $keywords . $tag-&gt;name . ", ";}echo $keywords;}else{echo ("在这里是填写你网站首页的关键字");} ?&gt;" /&gt;</p>
<p><strong>找到如下代码：</strong></p>
<p>把&lt;meta name="description" content="这里是你网站首页的描述" /&gt;</p>
<p>替换为：</p>
<p>&lt;meta name="description" content="&lt;?php if (is_single()){ echo mb_strimwidth(strip_tags(apply_filters('the_content', $post-&gt;post_content)), 0, 180,"");} else{echo ("在这里是填写你网站首页的描述");}?&gt;" /&gt;<br />
<strong>然后：</strong>点击“更新文件”保存设置，这样就Ok了！</p>
</div>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a>  原文地址：<a href="http://www.yunda51.com/758.html">http://www.yunda51.com/758.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=758</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>WordPress主题制作如何添加小工具功能</title>
		<link>https://www.yunda51.com/?p=471</link>
		<comments>https://www.yunda51.com/?p=471#comments</comments>
		<pubDate>Mon, 10 Dec 2012 05:29:46 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[php技术]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=471</guid>
		<description><![CDATA[第一步打开主题下面的functions文件，追加下面代码（注意：这代码是加在&#60;?php     这里 ?<a href="https://www.yunda51.com/?p=471" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>第一步打开主题下面的functions文件，追加下面代码（注意：这代码是加在&lt;?php     这里 ?&gt;千万不要在?&gt;的后面一定是前面哈）<br />
if ( function_exists('register_sidebar') )<br />
register_sidebar(array(<br />
'before_widget' =&gt; '&lt;div&gt;        ',<br />
'after_widget' =&gt; '&lt;/div&gt;',<br />
'before_title' =&gt; '&lt;h2&gt;',<br />
'after_title' =&gt; '&lt;/h2&gt;',<br />
));<br />
然后保存重新上传functions.php文件。<br />
第二步，打开sidebar.php，在最上面添加&lt;?php if ( !function_exists('dynamic_sidebar')<br />
|| !dynamic_sidebar() ) : ?&gt;<br />
然后在最下面添加&lt;?php endif; ?&gt;然后保存，重新上传sidebar.php。<br />
那么刷新一下后台，点击外观-小工具，就会显示出来了，这样就ok了~我刚才自己已经试过成功了，希望你们也能成功哈！</p>
<p>转载请注明转自:<a href="http://www.yunda51.com/">运达's blog</a>（原文地址： <a href="http://www.yunda51.com/?p=471">http://www.yunda51.com/?p=471</a>）</p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=471</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress首页文章摘要旁边显示缩略图的方法</title>
		<link>https://www.yunda51.com/?p=254</link>
		<comments>https://www.yunda51.com/?p=254#comments</comments>
		<pubDate>Sun, 25 Nov 2012 12:42:28 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=254</guid>
		<description><![CDATA[首先贴出所需的css代码，放到你的主题文件style.css里面，要显示的图片的大小可以通过下面的width和<a href="https://www.yunda51.com/?p=254" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>首先贴出所需的css代码，放到你的主题文件style.css里面，要显示的图片的大小可以通过下面的width和height设置：</p>
<ol>
<li>.thumbnail_box {</li>
<li>    float: left;</li>
<li>    width: 140px;</li>
<li>    height:100px;</li>
<li>    margin: 17px 10px 8px 15px;_margin: 17px 10px 8px 7px;</li>
<li>    padding: 4px;</li>
<li>    border:1px solid #ccc;}</li>
<li>.thumbnail img{</li>
<li>    position:absolute;</li>
<li>    z-index:3;}</li>
<li>显示缩略图有两种方式:<br />
第一种：随机显示一张图片，这个需要在images文件夹下新建一个文件夹random，里面的图片最好事先处理好大小，名称统一为:tb+数字，如tb1.jpg，tb2.jpg…不要问偶为什么，程序就这么写的，实在懒得改，怕改错！<br />
代码如下，添加到主题文件index.php里面：</p>
<div>
<ol>
<li>&lt;div class="thumbnail_box"&gt;</li>
<li>    &lt;div class="thumbnail"&gt;</li>
<li>        &lt;?php if ( get_post_meta($post-&gt;ID, 'thumbnail', true) ) : ?&gt;</li>
<li>            &lt;?php $image = get_post_meta($post-&gt;ID, 'thumbnail', true); ?&gt;</li>
<li>            &lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="&lt;?php the_title(); ?&gt;"&gt;&lt;img src="&lt;?php echo $image; ?&gt;" alt="&lt;?php the_title(); ?&gt;" title="&lt;?php the_title(); ?&gt;" /&gt;&lt;/a&gt;</li>
<li>            &lt;?php else: ?&gt;</li>
<li>            &lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="&lt;?php the_title(); ?&gt;"&gt;&lt;img src="&lt;?php bloginfo('template_directory'); ?&gt;/images/random/tb&lt;?php echo rand(1,20)?&gt;.jpg" alt="&lt;?php the_title(); ?&gt;" title="&lt;?php the_title(); ?&gt;" /&gt;&lt;/a&gt;</li>
<li>            &lt;?php endif; ?&gt;</li>
<li>    &lt;/div&gt;&lt;/div&gt;</li>
</ol>
</div>
<p>第二种：先从文章中读取图片作为缩略图，如果文章中没有缩略图，再使用上一种方法里面建立的random文件夹里面的图片！<br />
分两步：首先往主题文件functions.php添加如下代码：</p>
<div>
<ol>
<li>if ( function_exists('add_theme_support') )</li>
<li> add_theme_support('post-thumbnails');</li>
<li> function catch_first_image() {</li>
<li>  global $post, $posts;</li>
<li>  $first_img = '';</li>
<li>  ob_start();</li>
<li>  ob_end_clean();</li>
<li>  $output = preg_match_all('/&lt;img.+src=[\'"]([^\'"]+)[\'"].*&gt;/i', $post-&gt;post_content, $matches);</li>
<li>  $first_img = $matches [1] [0];</li>
<li>  if(emptyempty($first_img)){</li>
<li>        $random = mt_rand(1, 20);</li>
<li>        echo get_bloginfo ( 'stylesheet_directory' );</li>
<li>        echo '/images/random/tb'.$random.'.jpg';</li>
<li>  }</li>
<li>  return $first_img;</li>
<li> }</li>
</ol>
</div>
<p>然后在往主题文件index.php里面添加如下代码：</p>
<ol>
<li>&lt;div class="thumbnail_box"&gt;</li>
<li>    &lt;div class="thumbnail"&gt;</li>
<li>        &lt;?php if ( get_post_meta($post-&gt;ID, 'thumbnail', true) ) : ?&gt;</li>
<li>            &lt;?php $image = get_post_meta($post-&gt;ID, 'thumbnail', true); ?&gt;</li>
<li>            &lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="&lt;?php the_title(); ?&gt;"&gt;&lt;img src="&lt;?php echo $image; ?&gt;" alt="&lt;?php the_title(); ?&gt;" title="&lt;?php the_title(); ?&gt;" /&gt;&lt;/a&gt;</li>
<li>            &lt;?php else: ?&gt;</li>
<li>            &lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="&lt;?php the_title(); ?&gt;"&gt;</li>
<li>&lt;?php if (has_post_thumbnail()) { the_post_thumbnail('thumbnail'); }</li>
<li>else { ?&gt;</li>
<li>&lt;img class="home-thumb" src="&lt;?php echo catch_first_image() ?&gt;" width="140px" height="100px" alt="&lt;?php the_title(); ?&gt;"/&gt;</li>
<li>&lt;?php } ?&gt;</li>
<li>&lt;/a&gt;</li>
<li>            &lt;?php endif; ?&gt;</li>
<li>    &lt;/div&gt;&lt;/div&gt;</li>
</ol>
</li>
</ol>
<p>这就ok了！（原文地址：<a href="http://www.yunda51.com/?p=254">http://www.yunda51.com/?p=254</a>）</p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=254</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
