久久精品水蜜桃av综合天堂,久久精品丝袜高跟鞋,精品国产肉丝袜久久,国产一区二区三区色噜噜,黑人video粗暴亚裔
站長百科 | 數(shù)字化技能提升教程 數(shù)字化時代生存寶典
首頁
數(shù)字化百科
電子書
建站程序
開發(fā)
服務(wù)器
辦公軟件
開發(fā)教程
服務(wù)器教程
軟件使用教程
運營教程
熱門電子書
WordPress教程
寶塔面板教程
CSS教程
Shopify教程
導(dǎo)航
程序頻道
推廣頻道
網(wǎng)賺頻道
人物頻道
網(wǎng)站程序
網(wǎng)頁制作
云計算
服務(wù)器
CMS
論壇
網(wǎng)店
虛擬主機
cPanel
網(wǎng)址導(dǎo)航
WIKI使用導(dǎo)航
WIKI首頁
最新資訊
網(wǎng)站程序
站長人物
頁面分類
使用幫助
編輯測試
創(chuàng)建條目
網(wǎng)站地圖
站長百科導(dǎo)航
站長百科
主機偵探
IDCtalk云說
跨境電商導(dǎo)航
WordPress啦
站長專題
網(wǎng)站推廣
網(wǎng)站程序
網(wǎng)站賺錢
虛擬主機
cPanel
網(wǎng)址導(dǎo)航專題
云計算
微博營銷
虛擬主機管理系統(tǒng)
開放平臺
WIKI程序與應(yīng)用
美國十大主機
編輯“
WordPress:Tag Templates
”
人物百科
|
營銷百科
|
網(wǎng)賺百科
|
站長工具
|
網(wǎng)站程序
|
域名主機
|
互聯(lián)網(wǎng)公司
|
分類索引
Xxf3325
(
討論
|
貢獻(xiàn)
)
2008年9月17日 (三) 17:47的版本
(新頁面: = Introduction = Since the advent of
Themes
in WordPress 1.5, changing the look and feel of your WordPress site has become fairly straightforward. For instance,...)
(差異) ←上一版本 |
最后版本
(
差異
) |
下一版本→
(
差異
)
跳轉(zhuǎn)至:
導(dǎo)航
、?
搜索
警告:您正在編輯的是本頁面的舊版本。
如果您發(fā)布該更改,該版本后的所有更改都會丟失。
警告:
您沒有登錄。如果您做出任意編輯,您的IP地址將會公開可見。如果您
登錄
或
創(chuàng)建
一個賬戶,您的編輯將歸屬于您的用戶名,且將享受其他好處。
反垃圾檢查。
不要
加入這個!
= Introduction = Since the advent of [[WordPress:Using Themes|Themes]] in WordPress 1.5, changing the look and feel of your WordPress site has become fairly straightforward. For instance, when a viewer clicks on a link to one of the Categories on your site, he or she is taken to a page listing the Posts from that particular Category in chronological order, from newest Posts at the top to oldest at the bottom. There are many display choices, including whether to display the complete post or post excerpts, and what additional information to display (title, author, publish date, last modified time, etc.). Each theme makes different choices, and you might want to change them. This article explains how to change what happens when the blog viewer is visiting one of your site's Category pages. This involves the use of Themes and Template files, so if you are new to template files, you might want to read [[WordPress:Using Themes]] and [[WordPress:Stepping Into Templates]] first. == What Template File is Used? == The first step in modifying what happens when someone visits a Category page is to figure out which of your theme's files is going to be used to display the posts. This is known as the [[WordPress:Template Hierarchy]]. In the case of categories, the hierarchy is fairly simple. For instance, suppose the ID number of the Category in question is '''6'''. The Template Hierarchy specifies that WordPress will use the ''first'' Template file it finds in your current Theme's directory from the following list: #<tt style="font-weight:bold; color:#036">category-6.php</tt> #<tt style="font-weight:bold; color:#036">category.php</tt> #<tt style="font-weight:bold; color:#036">archive.php</tt> #<tt style="font-weight:bold; color:#036">index.php</tt> That is, if you do not have a <tt style="font-weight:bold; color:#036">category-6.php</tt>, WordPress will check for a <tt style="font-weight:bold; color:#036">category.php</tt>, and so on. So, if you want to make the Category whose ID number is 6 look different from what it is currently (and different from other Category pages), you would want to create a <tt>category-6.php</tt> file. If you want to make all Category pages look different from other archive pages (such as date and author archives), then you would want to create or modify the <tt>category.php file</tt>. If you want to make changes to the look of all archive pages, you can create or modify the <tt>archive.php</tt> file. And if you modify the <tt>index.php</tt> file, you will affect your entire blog. If you need to create a new file, it is a good idea to copy it from the next file in the hierarchy that exists. For instance, if you want a special display for Category 6, begin by copying the <tt>category.php</tt> file, or if you don't have one, use <tt>archive.php</tt>, and so on. = Examples = Now that you've figured out which template file in your theme's directory you need to modify, in order to make changes to the look of Category pages, let's look at some examples. In these examples, when it says "edit your template file", it means to edit the file you chose in the section above. == Adding Text to Category Pages == === Static Text Above Posts === Suppose you want some static text displayed before the list of Posts on your Category page(s). By "static", we mean text that remains the same, no matter which posts will be displayed below, and no matter which category is being displayed. Here is how to do it: above [[WordPress:The Loop]] section of your Template file, insert the following code: <pre><nowiki> <p> This is some text that will display at the top of the Category page. </p></nowiki></pre> === Different Text on Some Category Pages === A slightly more complex possibility is that you want different text to display depending on which category page the visitor is viewing. Then you would add the "default" text to the main <tt>category.php</tt> file, and create special <tt>category-#.php</tt> files (with their own version of the text, as described in the Introduction) for each category that needs special text at the top. This does however create a lot of files in your theme directory, and can be avoided using the following code '''OUTSIDE''' the loop: <pre><nowiki> <?php if (is_category('Category A')) { ?> <p>This is the text to describe category A</p> <?php } elseif (is_category('Category B')) { ?> <p>This is the text to describe category B</p> <?php } else { ?> <p>This is some generic text to describe all other category pages, I could be left blank</p> <?php } ?> </nowiki></pre> This does the following. Checks to see if we are looking at Category A, if we are then show the first bit of text, but if we're not then check if we are looking at Category B. If we are then show that bit of text, and finally, if it is neither Category A or B, then show this default text. === Text Displaying Only on First Page of Archive === Another thing that can happen is that if your Category contains more posts than will fit on one page (according to the Options for Blog Reading you have set in the Administration panels of your blog), the category archive will split into multiple pages. And maybe you only want to display your static text if the viewer is on the first page of results, or you want to display different text for the other pages. To make this happen, you can use a PHP <tt>if</tt> statement, which looks at the value of the <tt>$paged</tt> WordPress variable (<tt>$paged</tt> is equal to the page number: 1 for the first page of results, 2 for the second page, etc.). It may sound complicated, but it's actually not too bad. Just put the following above [[WordPress:The Loop]]: <pre> <?php if ( $paged < 2 ) { ?> <p>Text for first page of Category archive.</p> <?php } else { ?> <p>Text for subsequent pages of Category. Can be left out.</p> <?php } ?> </pre> === Category Name === Another possibility is to put the category name at the top of the page. If this is not already part of your template, you can add it by doing something like this, above [[WordPress:The Loop]]: <pre> <p>Category: <?php single_cat_title(); ?></p> </pre> == Modifying How Posts are Displayed == === Excerpts vs. Full Posts === Perhaps you are looking to cut down on the size of your Category pages. You could do this by displaying excerpts rather than the entire content of each Post. To do this, you will just need to find where it says <tt style="font-weight:bold; color:#036">[[WordPress:Template Tags/the_content|the_content()]]</tt> inside [[WordPress:The Loop]] in your Template, and replace it with <tt style="font-weight:bold; color:#036">[[WordPress:Template Tags/the_excerpt|the_excerpt()]]</tt>. These will most likely be inside PHP tags: <pre> <?php the_excerpt(); ?> and <?php the_content(); ?> </pre> Conversely, if your Theme is currently displaying excerpts and you want full posts, replace <tt>the_exerpt</tt> with <tt>the_content</tt>. === Display Images Linking to Full Posts === Another thing that is interesting to do in a category archive page is to replace the post content with an image that links to your post. To do this, you will first need to put images into the Excerpt sections of your posts. Here's how to do that, for one post: # Upload an image on the post editing screen. # Switch to the "Code" editor, rather than the "Visual" editor. # Use the Uploads / Browse tab to insert the image into your post. Make sure to insert the full-sized image, with no link. # Copy the inserted HTML <tt>img</tt> tag, and paste it into the "Optional Excerpt" section of the post editing screen. # Finish writing the post content (you can remove the image), and publish the post. Now you will need to modify your template. We'll use a trick: the [[WordPress:Template Tags/the_excerpt_rss|the_excerpt_rss()]] Template Tag does not put a paragraph tag around the excerpt. So we can use it to insert the <tt>img</tt> HTML and put it inside a link. Here's what you need to put into your Template, in place of using <tt>the_content</tt>: <pre> <a href="<?php the_permalink() ?>"> <?php the_excerpt_rss(); ?> </a> </pre> Caveat: using the excerpt this way '''may''' effect your RSS feed, because it places an img tag in the excerpt, instead of text. So if you are going to do this, you probably want to set your options so that the full posts are put in RSS feeds, rather than excerpts. === What categories do you show to the visitors? === You can limit the categories in archive and other pages with this code: <pre> <?php query_posts('cat=1&showposts='.get_option('posts_per_page')); ?> </pre> This is placed before the Loop. You find more info about the query_posts() function parameters here: http://codex.wordpress.org/User:JamesVL/query_posts . The <tt>get_option('posts_per_page')</tt> part of the code uses your blog's options to show a limited number of posts. This code is very useful if you would like to separate the categories. With this code you can make multiple archives. For example: <pre> <?php if (have_posts()) : ?> <?php if (is_month()) {query_posts('year='.get_the_time('Y').'&monthnum='.get_the_time('m').'&author_name=admin&cat=1&showposts='.get_option('posts_per_page')); ?> <!-- Do stuff... -> <?php } ?> <?php while (have_posts()) : the_post(); ?> <!-- post's contents --> <?php endwhile; ?> <?php endif; ?> </pre> If you use this code in <tt>archive.php</tt> and navigate to <tt>http://yourblog.com/2008/02/</tt>, show you the <tt>admin</tt> user's post that is posted on 2008.02. in the "first" category. = Related = {{Tag Category Tags}} {{Query String Tag Footer}} = Further Reading = * [http://wordpress.org/support/topic/38046 Support Forum discussion of Category-based theme] - how to make a Theme that organizes posts by category instead of by date on the home page * [[WordPress:Templates]] - Comprehensive list of resources related to Themes and Templates
摘要:
請注意,您對站長百科的所有貢獻(xiàn)都可能被其他貢獻(xiàn)者編輯,修改或刪除。如果您不希望您的文字被任意修改和再散布,請不要提交。
您同時也要向我們保證您所提交的內(nèi)容是您自己所作,或得自一個不受版權(quán)保護(hù)或相似自由的來源(參閱
Wordpress-mediawiki:版權(quán)
的細(xì)節(jié))。
未經(jīng)許可,請勿提交受版權(quán)保護(hù)的作品!
取消
編輯幫助
(在新窗口中打開)
本頁使用的模板:
模板:Query String Tag Footer
(
編輯
)
模板:Tag Category Tags
(
編輯
)
模板:查詢字符串標(biāo)簽頁底文字
(
編輯
)
模板:標(biāo)簽類別標(biāo)簽
(
編輯
)
取自“
http://kktzf.com.cn/wiki/WordPress:Tag_Templates
”