站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Adding Asides
”(章节)
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
== 拥有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>
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)