WIKI使用導(dǎo)航
站長百科導(dǎo)航
站長專題
- 網(wǎng)站推廣
- 網(wǎng)站程序
- 網(wǎng)站賺錢
- 虛擬主機(jī)
- cPanel
- 網(wǎng)址導(dǎo)航專題
- 云計(jì)算
- 微博營銷
- 虛擬主機(jī)管理系統(tǒng)
- 開放平臺
- WIKI程序與應(yīng)用
- 美國十大主機(jī)
WordPress:Creating a Static Front Page
UPDATE: With the release of WordPress Version 2.1, the option to set your own front page can be accomplished via your Administration > Settings > Reading panel. However unlike the old explanation that follows, you must NOT name your home page template file "home.php". If you do, this will cause a conflict with the WordPress 2.1 system. The approach that follows on this page is no longer necessary with WordPress 2.1 or newer
更新: 隨著WordPress 2.1版本的發(fā)行,可以通過, 管理 > 設(shè)置 > 閱讀 面板設(shè)置你自己的首頁。 然而與先前的說明不同,你不能將你的注意模板文件命名誒"home.php"。如果你那樣命名了,會與WordPress2.1系統(tǒng)產(chǎn)生沖突。這個網(wǎng)頁下面的方法不再適用于WordPress2.1版本或者更新的版本。
Known as a static front page or splash page, this is the first page seen by users entering your site. Unlike a traditional WordPress front page, featuring the WordPress Loop which generates a list of your most recent posts, the static front page is a customized page that lacks WordPress:The Loop and displays static information that can either invite people to "click through" to the real good stuff or offer highlighted post or article features and information that direct users to different areas of your WordPress site. It can have static information and links that do not change, or it can incorporate some automatically changing information.
作為靜態(tài)首頁 或者 splash page,這是用戶進(jìn)入你的站點(diǎn)首先看到的網(wǎng)頁。與傳統(tǒng)的WordPress首頁不同,傳統(tǒng)的首頁擁有WordPress Loop,產(chǎn)生你最近所寫文章的列表,而靜態(tài)首頁是個自定義的網(wǎng)頁,缺少The Loop并且顯示靜態(tài)的信息,能夠邀請人們"點(diǎn)擊到"真正的好內(nèi)容,或者提供突出的文章或者帖子功能和信息,能夠?qū)⒂脩魧?dǎo)向WordPress網(wǎng)站的不同區(qū)域??梢該碛徐o態(tài)的信息和鏈接,信息和鏈接不會更改,或者可以包含一些動態(tài)的,可以更改的信息。
This page contains a technique that requires editing several files. There's a different, shorter technique to get a static front page while maintaining a separate blog area, that is based on WordPress's static pages, and another one that works entirely with template files. Both of these techniques, unlike WordPress 2.1's front page setting, lend themselves to creating a richer, more interactive front page.
這個網(wǎng)頁包含有一種方法,需要編輯幾個文件。有一個不同的,更簡單的的方法,得到為靜態(tài)網(wǎng)頁的同時,保持分開的博客區(qū),以WordPress靜態(tài)頁面為基礎(chǔ),而且http://www.nyceducated.info/blog/internet/the-real-ultimate-static-front-page/ 另一個完全與模板文件一起運(yùn)行]。兩種方法,與WordPress2.1的首頁設(shè)置不同,能夠創(chuàng)建內(nèi)容更豐富,更具有互動性的首頁。
Using WordPress as CMS[ ]
將WordPress用在CMS[ ]
If your goal is to have a WP-created Page with static information called "Home" at example.com/, and the standard blog index at example.com/news/, the method below may cause the more tag to fail.
如果你的目的是使得WP創(chuàng)建的網(wǎng)頁的稱為"主頁"的靜態(tài)信息,位于example.com/,而標(biāo)準(zhǔn)的博客索引位于example.com/news/,下面的例子可能導(dǎo)致更多的標(biāo)簽失效。
Use a plugin such as Filosofo Home-Page Control instead. It works fine with WP installed in root.
使用一個插件,例如Filosofo 主頁控制。這個插件能夠與安裝在根目錄上的插件,一起運(yùn)行。
Create and Upload a Static Front Page[ ]
創(chuàng)建并且上傳靜態(tài)首頁[ ]
By default, most websites feature their main page as one of the following, and you can set yours to be any of these:
默認(rèn)情況下,大多數(shù)網(wǎng)站的主頁類似于下面的一種形式,而且你可以將你的主頁設(shè)置為下面的一種形式:
- index.html
- home.html
- index.php
- home.php
- default.htm
- index.html
- home.html
- index.php
- home.php
- default.htm
To create your static front page: 要創(chuàng)建你的靜態(tài)首頁:
- Using a text editor, open a blank document.
- 使用一個文本編輯器,打開一個空白的文檔。
- Design the inside of your Static Front Page.
- 設(shè)置你的靜態(tài)首頁的內(nèi)部內(nèi)容。
- Save it with any name listed above (Example: home.php).
- 用以上列出的任何名稱,保存這個文檔(例如:home.php)。
- If you have WordPress in another folder, upload your static page to your root HTML folder.
- 如果你將WordPress放在另一個文件夾,將你的靜態(tài)網(wǎng)頁上傳到你的根HTML文件夾。
Please note that your static page
請注意你的靜態(tài)網(wǎng)頁
may need to have the file extension ".php" in order for the PHP code to be processed. 可以需要文件擴(kuò)展名".php",以使得PHP代碼能夠得到處理。
If your static page is "index.html", then the PHP code may not be executed.
如果你的靜態(tài)網(wǎng)頁是"index.html",那么PHP代碼可能得不到執(zhí)行。
Install WordPress in its own folder or, if you have already installed it, consider moving WordPress to its own folder (or follow instructions below if you do not want to move entire WordPress core files -- but you might have some problems when upgrading).
安裝 WordPress到WordPress自己的文件夾,或者如果你已經(jīng)安裝了WordPress,考慮移動WordPress到WordPress自己的文件夾(或者如果你不想要移動整個WordPress核心文件,你可以遵循以下的指示說明--但是 升級WordPress的時候,你可能會遇到一些麻煩)。
If WordPress is in Root[ ]
如果WordPress在根目錄上[ ]
If you do not want to move your WordPress installation to another folder, or you are in a hurry, you can use these instructions or look [[WordPress:#Change Apache Configuration File|below]].
如果你不想將WordPress安裝移到 另一個文件夾,或者如果你比較匆忙,你可以使用這些指示說明或者查看 [[WordPress:#Change Apache Configuration File|下面的]]。
- Create a new folder on your site server for WordPress index.php file.
- 在你的站點(diǎn)服務(wù)器上為WordPressindex.php文件創(chuàng)建新的文件夾。
- Download index.php WordPress file and open it in a text editor.
- 下載index.php文件并且在文本編輯器中將其打開。
- Change the require('./wp-blog-header.php'); line to require('../wp-blog-header.php');
- 將require('./wp-blog-header.php');命令行更改為require('../wp-blog-header.php');
- Save and upload the modified index.php file into the new folder.
- 保存并給將更改過的index.php文件上傳到新的文件夾。
- Login into your WordPress Administration Panel and go to Settings > General.
- Change your Blog URI pointing to the new folder. For example, if your site is http://example.com, and the new folder is called blog, enter http://example.com/blog.
- 更改你的博客URL,指向新的文件夾。例如,如果你的站點(diǎn)是http://example.com,而且新的文件夾稱為blog,輸入http://example.com/blog。
Now, upload your splash page to your root server folder. 現(xiàn)在,將你的splash 頁面上傳到你的根服務(wù)器文件夾。
Change Apache Configuration File[ ]
更改 Apache 配置文件[ ]
There is another form to upload your static front page without moving all your WordPress files to another folder.
有另一種形式可以上傳你的靜態(tài)首頁,但是不會將你的所有的WordPress文件移到另一個文件夾。
When you request a folder in a Apache web server (for example the folder called /chouette), the core of Apache will search for a file with any of the names in a list saved in httpd.conf. If your server lets you use .htaccess files for change the original configuration, you can follow these steps:
當(dāng)你在Apache網(wǎng)絡(luò)服務(wù)器上尋求文件夾的時候(例如文件夾稱為/chouette),Apache的核心會搜索文件,文件擁有保存在httpd.conf中的列表上列出的任何名稱。如果你的服務(wù)器允許你使用.htaccess文件,來更改原始配置,你可以遵循以下的這些步驟:
- Open the .htaccess file from your root web folder in a text editor.
- At the top of the file, add:
- 在一個文本編輯器中打開來自你的根網(wǎng)絡(luò)文件夾中的.htaccess文件。
- 在文件的頂上方,添加:
DirectoryIndex home.php index.php
DirectoryIndex home.php index.php
Save and upload the modified .htaccess file.
保存并且上傳更改過的.htaccess文件。
You need to mention index.php as a second choice, otherwise you will not be able to access the index.php in directories below the wordpress root directory unless you explicitly mention it in the URL. For instance, the url:
你需要將index.php看做第二種選擇,否則,你就不能訪問WordPress根目錄下面的目錄中的index.php,除非你在URL中清楚地提及了。例如,url:
http://<wordpress root URL>/wp-admin/
http://<wordpress root URL>/wp-admin/
would not work. 不能夠運(yùn)行。
Integrating WordPress[ ]
與WordPress 結(jié)合[ ]
To incorporate or integrate WordPress with your static front page, you can include the header, sidebar, footer, and even a mini-version of the WordPress Loop.
將WordPress與你的靜態(tài)首頁相結(jié)合,你可以包含標(biāo)頭,邊欄,頁底文字,設(shè)置WordPress Loop的微型版本。
Include the Header[ ]
包含標(biāo)頭[ ]
To include the header from your WordPress Theme to maintain a consistent look, add this to the top of the page, using the folder path name you installed WordPress into:
要包含來自WordPress 主題的標(biāo)頭,來維持整體的外觀,將這個添加到網(wǎng)頁的頂端,使用你安裝WordPress的文件夾路徑名:
<?php define('WP_USE_THEMES', false); require('./wordpress/wp-blog-header.php'); get_header(); ?>
<?php define('WP_USE_THEMES', false); require('./wordpress/wp-blog-header.php'); get_header(); ?>
The purpose of requiring or including wp-blog-header.php is to let you make use of any WordPress function or template tag. When you include it in your page a function such as get_header() becomes available, just as it is in the standard WordPress templates.
需求或者包含wp-blog-header.php的目的是使得你能夠利用任何WordPress函數(shù)或者模板標(biāo)簽。當(dāng)你在網(wǎng)頁中包含了一個標(biāo)簽,就可以擁有函數(shù),例如get_header() ,因?yàn)樗窃跇?biāo)準(zhǔn)的WordPress模板中。
Note: In rare cases defining the WP_USE_THEMES
constant to false may produce non-CSS formatted page output. To workaround this you can try replacing ('WP_USE_THEMES', false)
with ('WP_USE_THEMES', true)
.
注:在很少的一些例子中,將定義code>WP_USE_THEMES常數(shù)定義為錯誤的,可能會導(dǎo)致非CSS格式網(wǎng)頁的產(chǎn)生。要處理這個問題,你可以試著用('WP_USE_THEMES', true)
替換('WP_USE_THEMES', false)
。
Include The Sidebar or Footer[ ]
包含邊欄或者頁底文字[ ]
To add the sidebar and/or footer from your WordPress Theme, include one or both of the following at the bottom of the page, using the same folder path:
要包含來自WordPress主題的邊欄和/或者頁底文字,在網(wǎng)頁的底部包含下面的一項(xiàng)或者兩項(xiàng),使用相同的文件夾路徑:
<?php get_sidebar(); ?> <?php get_footer(); ?>
<?php get_sidebar(); ?> <?php get_footer(); ?>
Adding a Mini-Loop[ ]
添加個微型Loop[ ]
You can incorporate a customized-version of the WordPress Loop in a static page to generate a short list of the latest posts on your WordPress blog. This "mini-Loop" acts like a feed, displaying your posts in a non-WordPress, PHP document. Change the value for $how_many to reflect the number of posts you want to show, and make sure the path to your wp-config.php file is correct.
你可以將自定義版本的WordPress Loop結(jié)合到靜態(tài)頁面,產(chǎn)生WordPress博客上最新的文章的簡短的列表。這個"微型的Loop"就如一個feed,在非WordPress,PHP文檔上顯示你的文章。更改$how_many的參數(shù)值,反映你想要顯示的文章的數(shù)目,并且確定打到你的wp-config.php文件的路徑是正確的。
<?php $how_many=5; //How many posts do you want to show require_once('wp-config.php'); // Change this for your path to wp-config.php file ?> <ol id="whats-new"> <? $news=$wpdb->get_results("SELECT `ID`,`post_title` FROM $wpdb->posts WHERE `post_type`=\"post\" AND `post_status`=\"publish\" ORDER BY post_date DESC LIMIT $how_many"); foreach($news as $np){ printf ("<li><a href=\"index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title); }?> </ol>
<?php $how_many=5; //How many posts do you want to show require_once('wp-config.php'); // Change this for your path to wp-config.php file ?> <ol id="whats-new"> <? $news=$wpdb->get_results("SELECT `ID`,`post_title` FROM $wpdb->posts WHERE `post_type`=\"post\" AND `post_status`=\"publish\" ORDER BY post_date DESC LIMIT $how_many"); foreach($news as $np){ printf ("<li><a href=\"index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title); }?> </ol>
Also, change "index.php" in the printf statement to include the path to the index.php in your installation directory.
同時,更改printf聲明中的"index.php",包含路徑,到達(dá)你的安裝目錄中的index.php。
Alternatively, if using custom WordPress:Permalinks on your blog, you can set the code to retrieve the permalink for each article and use this as the link to the post. This helps with indexing of your site by search engines such as Google, which can blacklist your site if it considers that pages duplicate content (the same content would be accessible both by using the address {YourWordPressURL}/?p=x and {YourWordPressURL}/permalink-address/). To use permalinks on your static page:
此外,如果在你的博客上使用自定義的WordPress:Permalinks,你可以設(shè)置代碼,返回每篇文章的permalink并且使用這個作為鏈接到文章的鏈接。這樣能夠幫助搜索引擎,如Google,索引你的站點(diǎn),如果搜索引擎認(rèn)為網(wǎng)頁復(fù)制了內(nèi)容(通過使用{YourWordPressURL}/?p=x 和{YourWordPressURL}/permalink-address/地址,可以得到同樣的內(nèi)容),可以將你的站點(diǎn)記入黑名單。在你的靜態(tài)頁面上使用permalinks:
<?php $how_many=5; //How many posts do you want to show require_once('wp-config.php'); // Change this for your path to wp-config.php file ?> <ol id="whats-new"> <? $news=$wpdb->get_results("SELECT `ID`,`post_title` FROM $wpdb->posts WHERE `post_type`=\"post\" AND `post_status`=\"publish\" ORDER BY post_date DESC LIMIT $how_many"); foreach($news as $np){ printf ("<li><a href=\"%s\">%s</a></li>", get_permalink($np->ID),$np->post_title); } ?> </ol>
<?php $how_many=5; //How many posts do you want to show require_once('wp-config.php'); // Change this for your path to wp-config.php file ?> <ol id="whats-new"> <? $news=$wpdb->get_results("SELECT `ID`,`post_title` FROM $wpdb->posts WHERE `post_type`=\"post\" AND `post_status`=\"publish\" ORDER BY post_date DESC LIMIT $how_many"); foreach($news as $np){ printf ("<li><a href=\"%s\">%s</a></li>", get_permalink($np->ID),$np->post_title); } ?> </ol>
In either case, posts will appear in an ordered list with the CSS ID whats-new. With WordPress:CSS you can change the look of the mini-Loop to suit your own site design.
在兩個例子中,文章會在有序列表中出現(xiàn),擁有CSS IDwhats-new。擁有CSS,你可以更改微型loop的外觀,適應(yīng)你自己的站點(diǎn)設(shè)計(jì)。
Using Feedburner?[ ]
使用 Feedburner?[ ]
If you are already using Feedburner to manage your feeds, have a look at their "BuzzBoost" feature under Publicize.
如果你已經(jīng)使用 With just a small piece of javascript you can add your recent posts to any html page. Very customizable as well.
只有有一點(diǎn)javascript,你就可以將你最近的文章添加到任何html頁面。很容易自定義。
(More on WordPress:Using_FeedBurner)
(更多的請看Using_FeedBurner)
What you do with your static front page is up to you and your imagination. Here are a few examples to help you see the possibilities.
你想要怎樣處理靜態(tài)首頁,取決于你自己和你的想象力。下面有幾個例子,幫助你看看可以怎樣處理靜態(tài)首頁。
thumb|right|Look of the code on your left
典型的歡迎靜態(tài)首頁,可能會有問候,解釋了站點(diǎn)是關(guān)于什么的,同時歡迎用戶點(diǎn)擊不同的鏈接,進(jìn)入站點(diǎn)??赡馨恼抡蛘哝溄?,鏈接到文章或者帖子,站點(diǎn)管理員可以動手更改這樣的設(shè)置。
Here is an example of a simple, typical page structure:
下面是一個例子,關(guān)于簡單而又典型的網(wǎng)頁結(jié)構(gòu):
To incorporate the mini-Loop into your static page review this example of a possible structure:
要將微型Loop與你的靜態(tài)網(wǎng)頁相結(jié)合,請看看這個結(jié)構(gòu)例子:
Examples[ ]
例子[ ]
Typical Page[ ]
典型的網(wǎng)頁[ ]
A typical welcome static page may feature a greeting that explains what the site is about and welcomes users to click on various links to enter the site. It could include summaries or links to articles or posts within, changed manually by the site administrator.
<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
get_header();
?>
<div id="content" class="narrowcolumn">
<h1>Welcome to my site</h1>
<p>Hello and welcome to my site. You can go to my web
page about how to improve your digital photography
techniques with your new digital camera; or you
can <a title="Go to my Blog" href="/wordpress/index.php">go
to my blog.</a></p></div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
get_header();
?>
<div id="content" class="narrowcolumn">
<h1>歡迎來到我的站點(diǎn)Welcome to my site</h1>
<p>你好,歡迎來到我的站點(diǎn)。你可以進(jìn)入我的網(wǎng)頁,網(wǎng)頁關(guān)于怎樣使用新的數(shù)碼相機(jī)提高你的數(shù)碼攝影技術(shù);或者你可以
<a title="進(jìn)入我的博客" href="/wordpress/index.php">進(jìn)入我的博客。</a></p></div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Static Page with Mini-Loop[ ]
擁有微型Loop的靜態(tài)網(wǎng)頁[ ]
<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
get_header();
?>
<div id="content" class="narrowcolumn">
<h1>Welcome to my site.</h1>
<p>Hello and welcome to my site. You can go to my web page about how to improve your
shoots with your digital camera; or you can go to my blog</p>
<h2>Latest posts in my blog:</h2>
<?php
# Here starts Mini Loop trick: You can use this code, but _at your own risk_
# If you want to improve this code, you're welcome ;)
$how_many=7; //How many posts do you want to show
?>
<ul class="whats-new">
<?php
$news=$wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts
WHERE `post_type`=\"post\" AND `post_status`= \"publish\" ORDER BY `post_date` DESC LIMIT $how_many");
foreach($news as $np){
printf ("<li><a href=\"index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title);
}
?>
</ul></div>
<?php
get_sidebar();
get_footer();
?>
<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
get_header();
?>
<div id="content" class="narrowcolumn">
<h1>歡迎來到我的站點(diǎn)</h1>
<p>你好,歡迎來到我的站點(diǎn)。你可以進(jìn)入我的網(wǎng)頁,網(wǎng)頁關(guān)于怎樣使用新的數(shù)碼相機(jī)提高你的數(shù)碼攝影技術(shù);或者你可以進(jìn)入我的博客。</p>
<h2>我的博客中最新的文章:</h2>
<?php
# 下面開始微型Loop方法: 你可以使用這個代碼量, but _at your own risk_
#如果你想要改善這個代碼,歡迎你那樣操作; ;)
$how_many=7; //你想要顯示多少篇文章
?>
<ul class="whats-new">
<?php
$news=$wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts
WHERE `post_type`=\"post\" AND `post_status`= \"publish\" ORDER BY `post_date` DESC LIMIT $how_many");
foreach($news as $np){
printf ("<li><a href=\"index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title);
}
?>
</ul></div>
<?php
get_sidebar();
get_footer();
?>