WordPress:Adding Asides
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 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最初是由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 Loop, but if you are careful, everything will be all right.
使用Asides,需要你更改WordPress Loop,但是如果你非常小心,一切都会顺利。
Asides With a Plug-In[ ]
拥有插件程序的Asides[ ]
The MiniPosts2 plugin allows you to flag any post as an aside, without having to edit code or create special categories. It uses the 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.
MiniPosts2插件能够使你将任何文章标记为aside,你也不用编辑代码或者创建新的类别。这个插件使用widgets 插件能使你轻易地控制你的工具条中aside列表的布局。要将一篇文章做出aside,你只要选择文章编辑网页上的框。
See also SideBlog which runs as a widget or via normal sidebar hacking.
也看看http://katesgasis.com/2006/05/02/sideblog-plugin-v30/ SideBlog],像widget运行或者通过普通的工具条hacking。
The 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 Administration Panel and assign it to a category which contain aside posts. AsideShop does not add any information to posts or categories.
AsideShop能使你在博客首页上以不同的方式显示aside 文章,不用更改主题模板。在管理面板中创建一个模板并且将模板递交到含有aside文章的类别中。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[ ]
center|frame|Asides at photomatt.netThe 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.
center|frame| photomatt.net中的Asides下面是一步一步的指导,关于怎样动手向你的WordPress站点添加Asides。下面是一些WordPress插件,会使整个添加过程变得更加简单。
- 1. Make a backup copy of your index.php in your WordPress Theme, typically found at /wp-content/themes/yourtheme. Seriously. BACK IT UP!!
- 1.在/wp-content/themes/yourtheme中的WordPress主题中制作index.php文件备份。非常重要。快点备份!!
- 2. In your WordPress:Administration Panels > Manage > 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.在你的管理面板 > 管理 > 类别中为你的Asides添加一个类别。如果你想的话,你可以称这个类别为Asides。注意类别的ID数字。在下面的例子中,我们会使用类别ID14,但是你可以将这个数字更改为你的Asides类别的ID。
- 3. Open your Theme's index.php template file in a text editor.
- 4. Search for:
- 4.搜索:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
- Comment it out like this:
<?php //if (have_posts()) : while (have_posts()) : the_post(); ?>
- 5. Under this paste:
<?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(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
- Comment it out like this:
<?php //if (have_posts()) : while (have_posts()) : the_post(); ?>
- 5. Under this paste:
<?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(); ?>
- 6. The next line should be your date call (<?php the_date(); ?>). Under that, paste this:
- 6.下一行应该是你的日期call(<?php the_date(); ?>)。在日期call的下面,粘贴上这个:
<?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 ?>
- 7: At the bottom of the index.php file, find:
<?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?>
- 8. Delete those lines. And instead, paste these lines:
<?php endif; // end if in category ?> <?php } } else { echo '<p>Sorry no posts found.</p>'; } ?>
<?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网页?>
- 7: At the bottom of the index.php file, find:
<?php endwhile; else: ?> <p><?php _e('对不起,没有网页能够符合你的标准。'); ?></p> <?php endif; ?>
- 8. 删除那些行,粘贴这些行:
<?php endif; // end if in category ?> <?php } } else { echo '<p>对不起,没有发现文章。</p>'; } ?>
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:
ul.linklog li { border:1px solid #ff0000; font:Verdana; font-size:14pt; background-color:#ffff00; } ul.linklog li a { text-decoration:none; }
ul.linklog li { border:1px solid #ff0000; font:Verdana; font-size:14pt; background-color:#ffff00; } ul.linklog li a { text-decoration:none; }
Displaying Asides on the Sidebar[ ]
在工具条上显示Asides[ ]
right|frame|Asides on the Sidebar at noscope.comREMEMBER: The following section has nothing to do with Matt's asides. They are INDEPENDENT of each other and will not work with each other.
right|frame| noscope.com中的工具条上的AsidesREMEMBER:下面的部分与Matt的asides没有任何关系,它们是互相独立的,而且不会在一起运行。
There are times when you want to display your Asides in your sidebar. In the sidebar.php 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 (<ul>) tags or within them as a List Item (<li>):
有时候,你想要在工具条内显示Asides。在WordPress主题的sidebar.php模板文件中,将下面的内容添加到你希望asides显示的位置。如果你希望asides出现在列表之外,确定将下面的内容放到无序列表(<ul>)标签的上面或者下面或者放到无序列表标签的内部作为列表内容(<li>):
<?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; ?>
<?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; ?>
Now, you can style the CSS for the div "asides_sidebar" to your liking in the style.css style sheet.
现在你可以在style.css样式表上,根据你的爱好,为div "asides_sidebar"设计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 index.php file:
在你的主要的index.php文件中的loop内找到这一行:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
Just after that line, paste this line (change the 14 to your category ID number):
在那一行的后面,粘贴这一行(将14更改为你的类别ID数):
<?php if (in_category('14') && is_home() ) continue; ?>
<?php if (in_category('14') && is_home() ) continue; ?>
After that, you will then need to find this line: 然后,你需要这个命令行:
<?php endwhile; ?>
<?php endwhile; ?>
And just before that line, paste this: 在那一行的前面,粘贴上这个:
<?php } ?>
<?php } ?>
After doing all of that, you will need to put this line:
做好之后,你需要放入这一行:
<?php rewind_posts(); ?>
<?php rewind_posts(); ?>
Either before the loop in your index.php file or before the loop in your sidebar.php file, depending on which one comes last. So, for example, if <?php get_sidebar(); ?> comes after the <?php endif; ?> line in index.php, then you will have to put it before the loop in sidebar.php.
在index.php文件的loop之前或者在sidebar.php文件的loop之前,取决于哪个速度更快。例如,如果<?php get_sidebar(); ?>在index.php中的<?php endif; ?>命令行之后,你需要将它放在sidebar.php中的loop中。
Voila. Asides will now be displayed on the sidebar, rather than within the loop, giving it a more 'linkblog' feel.
就是,Aside现在会显示在工具条中而不是loop内,使得其更有'链接博客'的特性。
Resources[ ]
资源[ ]
- Markku Seguerra's wp-recent-links plugin
- Tom Gilbert's WordPress del.icio.us Plugin displays your links from your de.icio.us account
- Russ's RustAsides Plugin
- Sideblog plugin