站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
建站程序
开发
服务器
办公软件
开发教程
服务器教程
软件使用教程
运营教程
热门电子书
WordPress教程
宝塔面板教程
CSS教程
Shopify教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Adding Asides
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
__TOC__ __TOC__ When you lean towards someone and tell them a little bit of information, you are making an "aside" comment. In blogs, you can do that on your blog by passing on small bits of information to your readers called '''Asides'''. 当你向某人倾斜并且告诉他们一点信息的时候,你正在发表一个"aside"评论。在博客中,你可以向你的读者传递一些称为'''Asides'''的信息,来发表"aside"评论。 Also known as ''remaindered links'' or ''linkblog'', Asides were originally implemented by [http://photomatt.net Matt Mullenweg], developer of WordPress, and it soon spread far and wide and became a very popular method of adding little bits of information to your blog. 也称为''remaindered 链接'' 或者 ''链接博客'', Asides最初是由[http://photomatt.net Matt Mullenweg],WordPress的开发人员执行的,但是不久Asides得到广泛地传播,变成了一种非常受欢迎的向你的博客添加一点信息的方法。 Asides can be run from within your WordPress site, and do not require installation of another blog. All you need is a few lines of code, and a new category. Asides可以在你的WordPress站点内部运行,不需要另外安装一个博客。你只要几行代码和一个新的类别即可。 Using Asides requires you to make some changes in the [[WordPress:The Loop|WordPress Loop]], but if you are careful, everything will be all right. 使用Asides,需要你更改[[WordPress:The Loop|WordPress Loop]],但是如果你非常小心,一切都会顺利。 == Asides With a Plug-In == == 拥有插件程序的Asides == The [http://www.piepalace.ca/blog/projects/miniposts/ MiniPosts2] plugin allows you to flag any post as an aside, without having to edit code or create special categories. It uses the [http://www.piepalace.ca/blog/projects/miniposts/ widgets plugin] to allow you easy control over the placement of your aside list in your sidebar. To mark a post as an aside, you just have to check a box on the post edit page. [http://www.piepalace.ca/blog/projects/miniposts/ MiniPosts2]插件能够使你将任何文章标记为aside,你也不用编辑代码或者创建新的类别。这个插件使用[http://www.piepalace.ca/blog/projects/miniposts/ widgets 插件]能使你轻易地控制你的工具条中aside列表的布局。要将一篇文章做出aside,你只要选择文章编辑网页上的框。 See also [http://katesgasis.com/2006/05/02/sideblog-plugin-v30/ SideBlog] which runs as a widget or via normal sidebar hacking. 也看看http://katesgasis.com/2006/05/02/sideblog-plugin-v30/ SideBlog],像widget运行或者通过普通的工具条hacking。 The [http://wordpress.org/extend/plugins/asideshop/ AsideShop] plugin allows you to show aside posts on your blog's frontpage in a different way without theme template modification. Make a template in [[WordPress:Administration_Panels|Administration Panel]] and assign it to a category which contain aside posts. [http://wordpress.org/extend/plugins/asideshop/ AsideShop] does not add any information to posts or categories. [http://wordpress.org/extend/plugins/asideshop/ AsideShop]能使你在博客首页上以不同的方式显示aside 文章,不用更改主题模板。在[[WordPress:Administration_Panels|管理面板]]中创建一个模板并且将模板递交到含有aside文章的类别中。[http://wordpress.org/extend/plugins/asideshop/ AsideShop]不向文章或者类别添加任何信息。 == Asides With Code Hacking == == 拥有Code Hacking的Aside == If you are comfortable editing PHP files, then these two approaches are for you. 如果你愿意编辑PHP文件,这里有两种方法适合你。 === Matt's Asides === === Matt的 Asides === [[WordPress:Image:asides-in-post.jpg|center|frame|Asides at photomatt.net]]The following are the step by step instructions for manually adding Asides to your WordPress site. Below are WordPress plugins that will make the process much easier. [[WordPress:Image:asides-in-post.jpg|center|frame| photomatt.net中的Asides]]下面是一步一步的指导,关于怎样动手向你的WordPress站点添加Asides。下面是一些WordPress插件,会使整个添加过程变得更加简单。 :1. Make a backup copy of your <tt>index.php</tt> in your [[WordPress:Using Themes|WordPress Theme]], typically found at <tt>/wp-content/themes/yourtheme</tt>. Seriously. BACK IT UP!! :1.在<tt>/wp-content/themes/yourtheme</tt>中的[[WordPress:Using Themes|WordPress主题]]中制作<tt>index.php</tt>文件备份。非常重要。快点备份!! :2. In your [[WordPress:Administration Panels]] > [[WordPress:Administration_Panels#Manage_-_Change_your_content|Manage]] > [[WordPress:Administration_Panels#Categories|Categories]] add a category for your Asides. You can call it '''Asides''' if you want. Note the Category ID number of the category. In the following examples we will use category ID 14, but you change this to the category ID of your Asides category. :2.在你的[[WordPress:Administration Panels|管理面板]] > [[WordPress:Administration_Panels#Manage_-_Change_your_content|管理]] > [[WordPress:Administration_Panels#Categories|类别]]中为你的Asides添加一个类别。如果你想的话,你可以称这个类别为'''Asides'''。注意类别的ID数字。在下面的例子中,我们会使用类别ID14,但是你可以将这个数字更改为你的Asides类别的ID。 :3. Open your Theme's <tt>index.php</tt> [[WordPress:Templates|template file]] in a [[WordPress:Glossary#Text Editor|text editor]]. :3.打开[[WordPress:Glossary#Text Editor|文本编辑器]]中你的主题的<tt>index.php</tt> [[WordPress:Templates|模板文件]]。 :4. Search for: :4.搜索: <pre> <?php if (have_posts()) : while (have_posts()) : the_post(); ?></pre> :Comment it out like this: <pre><?php //if (have_posts()) : while (have_posts()) : the_post(); ?></pre> :5. Under this paste: <pre><?php if ($posts) { function stupid_hack($str) { return preg_replace('|</ul>\s*<ul class="linklog">|', '', $str); } ob_start('stupid_hack'); foreach($posts as $post) { the_post(); ?></pre> <pre> <?php if (have_posts()) : while (have_posts()) : the_post(); ?></pre> :Comment it out like this: <pre><?php //if (have_posts()) : while (have_posts()) : the_post(); ?></pre> :5. Under this paste: <pre><?php if ($posts) { function stupid_hack($str) { return preg_replace('|</ul>\s*<ul class="linklog">|', '', $str); } ob_start('stupid_hack'); foreach($posts as $post) { the_post(); ?></pre> :6. The next line should be your date call (<tt><?php the_date(); ?></tt>). Under that, paste this: :6.下一行应该是你的日期call(<tt><?php the_date(); ?></tt>)。在日期call的下面,粘贴上这个: <pre><?php if ( in_category(14) && !is_single() ) : ?> <ul class="linklog"> <li id="p<?php the_ID(); ?>"><?php echo wptexturize($post->post_content); ?> <span><?php comments_popup_link('(0)', '(1)', '(%)')?> <a href="<?php the_permalink(); ?>" title="Permalink: <?php echo wptexturize(strip_tags(stripslashes($post->post_title), '')); ?>" rel="bookmark">#</a> <?php edit_post_link('(e)'); ?></span></li> </ul> <?php else: // If it's a regular post or a permalink page ?></pre> :7: At the bottom of the <tt>index.php</tt> file, find: <pre><?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?></pre> :8. Delete those lines. And instead, paste these lines: <pre><?php endif; // end if in category ?> <?php } } else { echo '<p>Sorry no posts found.</p>'; } ?></pre> <pre><?php if ( in_category(14) && !is_single() ) : ?> <ul class="linklog"> <li id="p<?php the_ID(); ?>"><?php echo wptexturize($post->post_content); ?> <span><?php comments_popup_link('(0)', '(1)', '(%)')?> <a href="<?php the_permalink(); ?>" title="Permalink: <?php echo wptexturize(strip_tags(stripslashes($post->post_title), '')); ?>" rel="bookmark">#</a> <?php edit_post_link('(e)'); ?></span></li> </ul> <?php else: //是一篇普通的文章还是一个permalink网页?></pre> :7: At the bottom of the <tt>index.php</tt> file, find: <pre><?php endwhile; else: ?> <p><?php _e('对不起,没有网页能够符合你的标准。'); ?></p> <?php endif; ?></pre> :8. 删除那些行,粘贴这些行: <pre><?php endif; // end if in category ?> <?php } } else { echo '<p>对不起,没有发现文章。</p>'; } ?></pre> That's it. Asides should now be working. Only thing that remains is styling the CSS. 就这么多了。Asides现在应该能够运行了。只要设计CSS,就可以了。 ====Styling Your Asides==== ====设计你的 Asides==== What we've done is create a very basic style. You should add your own style to blend it in with the rest of your site. 我们要做的是创建一个非常基本的样式。你应该添加你自己的样式并且将这个样式与站点的其它内容相结合。 To style the Asides, add these example lines to the CSS: 要设计Asides,将这些例子命令行添加到CSS: <pre>ul.linklog li { border:1px solid #ff0000; font:Verdana; font-size:14pt; background-color:#ffff00; } ul.linklog li a { text-decoration:none; }</pre> <pre>ul.linklog li { border:1px solid #ff0000; font:Verdana; font-size:14pt; background-color:#ffff00; } ul.linklog li a { text-decoration:none; }</pre> == Displaying Asides on the Sidebar == == 在工具条上显示Asides== [[WordPress:Image:asides-in-sidebar.jpg|right|frame|Asides on the Sidebar at noscope.com]]'''REMEMBER''': The following section has nothing to do with Matt's asides. They are INDEPENDENT of each other and will not work with each other. [[WordPress:Image:asides-in-sidebar.jpg|right|frame| noscope.com中的工具条上的Asides]]'''REMEMBER''':下面的部分与Matt的asides没有任何关系,它们是互相独立的,而且不会在一起运行。 There are times when you want to display your Asides in your sidebar. In the <tt>sidebar.php</tt> template file of your WordPress Theme, add the following where you wish the asides to appear. If you want them outside of the list, make sure to position this above or below the Unordered List (<tt><ul></tt>) tags or within them as a List Item (<tt><li></tt>): 有时候,你想要在工具条内显示Asides。在WordPress主题的<tt>sidebar.php</tt>模板文件中,将下面的内容添加到你希望asides显示的位置。如果你希望asides出现在列表之外,确定将下面的内容放到无序列表(<tt><ul></tt>)标签的上面或者下面或者放到无序列表标签的内部作为列表内容(<tt><li></tt>): <pre><?php if ($posts) : foreach ($posts as $post) : the_post(); ?> <?php if (in_category(14)) { ?> <div class="asides_sidebar"> <?php echo $post->post_excerpt ?> <?php the_content(); ?> <small><?php comments_popup_link(__('#'), __('(1)'), __('(%)')); ?> <?php edit_post_link('Edit', ' — '); ?></small> </div> <?php } ?> <?php endforeach; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?></pre> <pre><?php if ($posts) : foreach ($posts as $post) : the_post(); ?> <?php if (in_category(14)) { ?> <div class="asides_sidebar"> <?php echo $post->post_excerpt ?> <?php the_content(); ?> <small><?php comments_popup_link(__('#'), __('(1)'), __('(%)')); ?> <?php edit_post_link('Edit', ' — '); ?></small> </div> <?php } ?> <?php endforeach; else: ?> <p><?php _e('对不起,没有文章符合你的标准。'); ?></p> <?php endif; ?></pre> Now, you can style the CSS for the <tt>div</tt> "<tt>asides_sidebar</tt>" to your liking in the <tt>style.css</tt> style sheet. 现在你可以在<tt>style.css</tt>样式表上,根据你的爱好,为<tt>div</tt> "<tt>asides_sidebar</tt>"设计CSS。 With Asides in the sidebar, you may want to disable them from being displayed within the main loop. This can be easily done with a snippet of code within the loop. Asides在工具条中,你可能想要阻止Asides在主要的loop内部显示。在loop内放一些代码,做到这一点,就很容易。 Find this line within the loop in your main <tt>index.php</tt> file: 在你的主要的<tt>index.php</tt>文件中的loop内找到这一行: <pre><?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?></pre> <pre><?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?></pre> Just after that line, paste this line (change the 14 to your category ID number): 在那一行的后面,粘贴这一行(将14更改为你的类别ID数): <pre><?php if (in_category('14') && is_home() ) continue; ?></pre> <pre><?php if (in_category('14') && is_home() ) continue; ?></pre> After that, you will then need to find this line: 然后,你需要这个命令行: <pre><?php endwhile; ?></pre> <pre><?php endwhile; ?></pre> And just before that line, paste this: 在那一行的前面,粘贴上这个: <pre><?php } ?></pre> <pre><?php } ?></pre> After doing all of that, you will need to put this line: 做好之后,你需要放入这一行: <pre><?php rewind_posts(); ?></pre> <pre><?php rewind_posts(); ?></pre> Either before the loop in your <tt>index.php</tt> file or before the loop in your <tt>sidebar.php</tt> file, depending on which one comes last. So, for example, if <tt><?php get_sidebar(); ?></tt> comes after the <tt><?php endif; ?></tt> line in <tt>index.php</tt>, then you will have to put it before the loop in <tt>sidebar.php</tt>. 在<tt>index.php</tt>文件的loop之前或者在<tt>sidebar.php</tt>文件的loop之前,取决于哪个速度更快。例如,如果<tt><?php get_sidebar(); ?></tt>在<tt>index.php</tt>中的<tt><?php endif; ?></tt>命令行之后,你需要将它放在<tt>sidebar.php</tt>中的loop中。 Voila. Asides will now be displayed on the sidebar, rather than within the loop, giving it a more 'linkblog' feel. 就是,Aside现在会显示在工具条中而不是loop内,使得其更有'链接博客'的特性。 == Resources == == 资源 == * [http://rebelpixel.com/projects/wp-recent-links/ Markku Seguerra's wp-recent-links plugin] * [http://linuxbrit.co.uk/blog/2004/10/01/wordpress-delicious-plugin-10/ Tom Gilbert's WordPress del.icio.us Plugin displays your links from your de.icio.us account] * [http://russ.innereyes.com/2005/01/the-rustasides-wp-15-plugin/ Russ's RustAsides Plugin] *[http://katesgasis.com/2005/10/24/sideblog/ Sideblog plugin] * [http://rebelpixel.com/projects/wp-recent-links/ Markku Seguerra的wp-recent-links 插件] * [http://linuxbrit.co.uk/blog/2004/10/01/wordpress-delicious-plugin-10/ Tom Gilbert's WordPress del.icio.us 插件 从你的de.icio.us account显示链接] * [http://russ.innereyes.com/2005/01/the-rustasides-wp-15-plugin/ Russ的RustAsides 插件] *[http://katesgasis.com/2005/10/24/sideblog/ Sideblog 插件]
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)