<?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>Widgets相关文章列表 | 皇家元林</title>
	<atom:link href="https://hjyl.org/tags/widgets/feed/" rel="self" type="application/rss+xml" />
	<link>https://hjyl.org</link>
	<description>刘元林的个人博客</description>
	<lastBuildDate>Wed, 13 Apr 2011 04:51:46 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://img.hjyl.org/uploads/2019/10/cropped-about-me-32x32.png</url>
	<title>Widgets相关文章列表 | 皇家元林</title>
	<link>https://hjyl.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>让你的WP主题支持多个Widgets</title>
		<link>https://hjyl.org/wptheme-widgets/</link>
					<comments>https://hjyl.org/wptheme-widgets/#comments</comments>
		
		<dc:creator><![CDATA[皇家元林]]></dc:creator>
		<pubDate>Wed, 13 Apr 2011 04:51:46 +0000</pubDate>
				<category><![CDATA[元林手札]]></category>
		<category><![CDATA[Widgets]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP主题]]></category>
		<category><![CDATA[小工具]]></category>
		<guid isPermaLink="false">http://hjyl.org/?p=1543</guid>

					<description><![CDATA[让你的WP主题支持多个Widgets]]></description>
										<content:encoded><![CDATA[<p>我很喜欢WordPress的小工具功能，只需要轻轻的一拖，就可以添加自己想要的内容。这两天我又开始想折腾个WP主题来，突然想做个三栏的，因为我也是第一次做超过两栏的主题，有些函数还是不会。后来在<a href="https://hjyl.org/go/aHR0cDovL3dvcmRwcmVzcy5vcmcuY24vdGhyZWFkLTExOTcxLTEtMS5odG1s" rel="nofollow" target="_blank">WordPress中文论坛</a>看到一段代码，觉得很简单，就挪过来用了。</p>
<p>先在function.php里加上这段，专业点就叫注册两个widget：</p>
<pre lang="language" line="1">
    if (function_exists('register_sidebar') )
        register_sidebar(array(
    'name' => 'Left Sidebar',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3><span class="star">',
        'after_title' => '</span></h3>',
        ));
    if (function_exists('register_sidebar') )
        register_sidebar(array(
    'name' => 'Right Sidebar',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '<h3><span class="star">',
        'after_title' => '</span></h3>',
        ));
</pre>
<p>调用方式,第一个</p>
<pre lang="language" line="1">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Left Sidebar") ) : ?>
<?php endif; ?>
</pre>
<p>调用方式,第二个</p>
<pre lang="language" line="1">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Right Sidebar") ) : ?>
<?php endif; ?>
</pre>
<p>还要更多的话，可以依此类推！</p>
<p>挺实用的，等待我下一个主题的效果吧！</p>
<div id="content-copyright"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;font-size: 13px;">版权声明: </span><span style="font-size: 13px;">本文采用 <a href="https://hjyl.org/go/aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzMuMC8=" rel="nofollow" target="_blank">BY-NC-SA</a> 协议进行授权，如无注明均为原创，转载请注明转自 <a href="https://hjyl.org">皇家元林</a><br>本文链接: <a rel="bookmark" title="让你的WP主题支持多个Widgets" href="https://hjyl.org/wptheme-widgets/">让你的WP主题支持多个Widgets</a></span></div>]]></content:encoded>
					
					<wfw:commentRss>https://hjyl.org/wptheme-widgets/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
	</channel>
</rss>
