How to Make HTML Pages Work Like Wordpress如何使HTML網頁一樣WordPress的工作
June 7th, 2007 · by David Bradley 2007年6月7日由戴維布拉德利
Do you have a bunch of standard html pages outside your Wordpress blog heirarchy?你有一大堆的標準HTML頁面之外的WordPress的博客層次? I’m not taking about Wordpress’ static “Pages” with a capital P, but those pages, perhaps in the root beyond the CMS facility of Wordpress.我不會考慮有關WordPress的'靜態“網頁”資本磷,但這些網頁,或許在以後生根不育系設施WordPress的。 Well, there is a relatively simple way to convert a standard html page into a kind of Wordpress page, so that your header, sidebar, and footer all render as if the page were a standard Wordpress page.嗯,是一個相對簡單的方式轉換成一個標準的HTML網頁使之成為一種WordPress的網頁,因此,您的標題,欄和頁腳所有提供的網頁,如果有一個標準的WordPress的頁面。
1. 1 。 First, make a back up of any pages you plan to change, then add this line to the head section of each page you want to re-theme within the Wordpress system on your site.首先,背部的任何網頁你計劃改變,然後加入這一行標頭區段的每一頁要重新主題的WordPress的系統在您的網站上。
<?php define(’WP_USE_THEMES’, false); require(’./your-wordpress-folder/wp-blog-header.php’); ?> “ ? PHP的界定( ' WP_USE_THEMES ' ,虛假) ;要求( ' 。 /你的WordPress的文件夾/可濕性粉劑,博客, header.php ' ) ; ? ”
That calls in the necessary code from the Wordpress folder (obviously change “your-wordpress-folder” to the actual directory name).這就要求在必要的代碼從WordPress的文件夾(明顯改變“你的WordPress的文件夾”的實際目錄名稱) 。
2. 2 。 Next, decide which components you’re going to need for the page.下一步,決定哪些部分你將需要的頁面。 You’ll probably want the header from your theme so add您可能會希望從您的頭,使新增的主題
<?php get_header(); ?> “ ?的PHP get_header ( ) ; ? ”
Put that near the top after the body tag.將這一上方附近後,身體標記。
3. 3 。 You’ve probably got a footer in your theme too, so add this to the bottom of the page before the close body tag您大概有頁腳在您的主題,所以加入到頁面底部的結束前身體標記
<?php get_footer(); ?> “ ?的PHP get_footer ( ) ; ? ”
4. 4 。 Then comes a tricky bit.然後是一個微妙位。 Where to put the sidebar?如果把欄? It depends.這取決於。 Try it just before the footer tag you added in the previous step first.試用前英尺標記你說在上一步第一次。 We can come back later and move it if it doesn’t work properly.我們可以回來後,移動如果它不能正常工作。
<?php get_sidebar(); ?> “ ?的PHP get_sidebar ( ) ; ? ”
5. 5 。 Now, smart readers will have noticed you’ve probably been adding a load of php tags to pages with an htm or an html and that opening these in your browser is just going to display the code without running it.現在,聰明的讀者會注意到您可能已經增加了負荷的PHP標籤頁的htm或一個HTML和開放這些在您的瀏覽器只是將顯示代碼不運行它。 So, there’s one final critical step you must take before things will work as planned.所以,有一個最後的關鍵一步你必須考慮的事情之前,將工作按計劃進行。 Open up your .htaccess file (you know where that is I take it, root folder, no filename just the extension htaccess (don’t forget the dot). Make a backup copy. Then add the following line:打開你的。 htaccess文件(你知道這是我是否可以,根文件夾,沒有文件只是延長htaccess (不要忘了點) 。備份。然後添加以下行:
AddHandler application/x-httpd-php .php .html .htm AddHandler申請/的X的httpd - PHP的。 PHP中。 HTML中。熱媒
and save the .htaccess file.並保存。 htaccess文件。 This will then allow the browser to parse the php in pages with the htm and html extensions as well as the php extension.這將允許瀏覽器解析PHP在網頁上的熱媒和HTML擴展以及PHP擴展。
Couple of things to watch out for: if you cut and paste the above code, ensure the quotes are single straight quote marks and the angle brackets are proper code not greater and less than signs.幾件事要留意:如果您剪切和粘貼上述代碼,確保引號是單直引號和尖括號是正確代碼,並沒有更大的不到跡象。
Also, make sure you double check the resulting meta tags for these pages, it might result in losing此外,一定要仔細檢查所產生的中繼標記這些網頁,它可能導致失去 RSS autodiscovery自動的RSS or changes in your carefully honed title tags.或更改您的仔細打磨標題標記。 Also, you generally will not be able to enable comments on these pages as you might do with a static Page within Wordpress proper.另外,您通常將無法啟用評論在這些網頁上你可以做靜態頁面內WordPress的正確。 If anyone knows how to workaround the comments disabled default for this kind of page, please leave a comment.如果有誰知道如何變通的評論殘疾默認這種頁面,請發表評論。 I’d love to enable comments across the whole of the Sciencebase.com site on which I make extensive use of this format.我喜歡的意見,使整個Sciencebase.com的網站上,我廣泛使用這種格式。




34 responses so far ↓ 34答复迄今↓
Why not just convert all your legacy pages (with a little p) into static pages within the Wordpress system and then relocate the subfolder to the site’s root?為什麼不只是您所有的轉換遺留的網頁(與小p )到靜態網頁的WordPress的系統,然後搬遷子網站的根? Job done.工作。
That would be one way of doing things, Ben, but what if you have thousands of pages in standard html, that’s an awful lot of cutting and pasting.這將是一個處事方式,本,但如果你有成千上萬的網頁在標準的HTML ,這是非常多的剪貼。 Also, there might be reasons why you want to keep the blog part in its own folder and have standalone chunks in the root.此外,還有可能是為什麼要保留一部分的博客在自己的文件夾,並有獨立的塊的根。
I’m having a problem doing the opposite of what you instructed.我有一個問題反其道而行之你的指示。 I want to add a bunch of html pages on the root of my directory and having a hard time.我想補充一群HTML網頁上的根源,我的目錄,並有一個艱苦的時間。
I would like a thankyou, about, seemore, page etc, and It keeps calling my 404 page.我想要一個thankyou ,約, seemore ,網頁等,它不斷打電話給我404頁。 how do I stop it?我怎麼阻止它?
Thanks.l
Deb, do you mean you are trying to create static pages in Wordpress called from the homepage, or are you making standalone pages but don’t want to have them use the WP template?德布,你意味著你是要創建靜態網頁在WordPress的所謂的首頁,或你製作獨立的網頁,但不想讓他們使用可濕性粉劑範本嗎? Please clarify and someone here might be able to assist.請說明有人在這裡可以為您提供幫助。
First thought, did you double check the links you’re using?首先想到的,你仔細檢查聯繫您使用?
db分貝
What i want to do is create standalone pages.我想要做的是建立獨立的網頁。 that don’t call the template.不要求模板。 I want a thankyou.html page for example.我想thankyou.html頁的例子。 And I can’t seem to get it working.我似乎無法得到工作。 it keeps calling the the template.它可以調用模板。
Also, I’ve created a folder called thankyou right at the root of the domain.另外,我建立了一個文件夾名為thankyou權利的根域。 added a page in it called index.html and the darn thing still calls the wp template.增加了一個網頁要求index.html和縫補的事情仍然調用可濕性粉劑範本。 I am totally baffled.我完全感到困惑。
Please help.請幫助。
Deb, that is very odd.德布,這是非常奇怪的。 If you are creating the pages within Wordpress then that’s bound to happen, but if you are simply creating a standard html page and then uploading it to the root then make sure you haven’t added the includes for WP.如果您正在創建的網頁內WordPress的那麼勢必發生,但是如果你僅僅是建立一個標準的HTML網頁,然後上傳到根然後確保你沒有說,包括為可濕性粉劑。 Could you either email the source code for the troublesome pages or point me to those pages and I’ll take a look.請問你要么電子郵件的源代碼的網頁或麻煩一點我對這些網頁,我會來看看。
db分貝
Thanks DB,由於數據庫,
You are right.你說得對。 That’s exactly what im trying to do.這正是免疫試圖這樣做。 However, i just can’t get the darn thing to work.但是,我不能讓織補的事情工作。
I am really frustrated at this point so im gonna go and hire some help.我真的很失望在這一點上,使免疫一定去聘請一些幫助。 A sista can’t be waisting three days trying to figure out this techie stuff阿sista不能waisting三天試圖找出這一技術人員的東西
Thanks for all your help though.感謝您所有的幫助了。
DG總幹事
please send the process of making html page請發送過程中的HTML網頁
Send it where Tathagat?發送Tathagat的地方? It’s right here.這是在這裡。 On the page在網頁上
db分貝
Hey,嗨,
I think I followed your directions exactly, but nothing is showing up on the page.我想我也跟著你的方向到底,但沒有出現在網頁上。
Ariela
Ariela, what is the file extension for the page? Ariela ,什麼是文件擴展名的網頁? If it’s not “.php” (could be .htm, .html instead), do you have those file extensions set to be read as php by your server?如果沒有“ 。 PHP的” (可能是。熱媒, 。代替的HTML ) ,你有這些文件擴展名設置為被理解為你的PHP的服務器?
to do that, you need this line in your .htaccess file:要做到這一點,你需要這條線在您的。 htaccess文件:
AddHandler application/x-httpd-php .php .html .htm AddHandler申請/的X的httpd - PHP的。 PHP中。 HTML中。熱媒
db分貝
Thanks for getting back to me so fast…謝謝回去我這麼快...
The file extension was .php, but I ended up going in a different direction — I’m building a theme to apply to the blog that looks just like my webpage.文件擴展名是。 PHP的,但我最終會在不同的方向-我建立一個主題,適用於博客,就像我的網頁。
Thanks, though!謝謝您,雖然!
Ah, okay, wonder why it failed then…caching perhaps?啊,不錯,不知道它為什麼失敗然後...也許緩存? Let us know how you get on.讓我們知道您上車。
You’ve got some lovely photos on your site by the way!你已經有了一些可愛的照片在您的網站上的方式! You may care to check out my public您可能會注意看看我的公開 flickr gallery Flickr的圖庫
db分貝
Hey, so I ended up building a theme that looked like my web page and everything worked, but I came across another problem, and am hoping that you have an answer.嘿,所以我最終建立一個主題,像我的網頁和一切工作,但我碰到的另一個問題,並很希望你有一個答案。 The one thing that’s not working is that the images aren’t showing up — they’re little blue diamonds with the question marks.一件事情沒有工作的是,圖像無法顯示-他們小藍鑽石的問號。 I checked and double checked all the image paths.我檢查和雙重檢查所有的圖片的路徑。 They are all, by the way, in the header.php and the footer.php.他們都是順便提一句,在header.php和footer.php 。 Any idea what I did wrong?任何知道我沒有錯了嗎?
Thanks!謝謝! (and thanks for the compliments on the photos — I’ll let the photographer know!) (和感謝,讚美的照片-我會告訴攝影師知道! )
That is brilliant.這是輝煌的。 Technical, but brilliant.技術,但輝煌。 I moved from HTML to WP a year ago and had a bunch of pages I just copied over cause I was too lazy to convert them.我搬到了從HTML到可濕性粉劑一年前,有一大堆的網頁我只是複製事業,我懶得轉換。
I am definitely bookmarking this page.我肯定書籤此網頁。 Thanks!謝謝!
Minnesota Investment Property’s last blog post.. 明尼蘇達州投資財產的最後的博客帖子.. Stupid Property Repairs #3 愚蠢的物業維修# 3
Luke // 盧克 / / Apr 23, 2008 at 3:55 am 2008年4月23號在上午03時55分
David,大衛
When I tried this, I got the following:當我試圖為此,我得到了以下內容:
Parse error: syntax error, unexpected ‘?’ in /xxxx/xxxx on line 159解析錯誤:語法錯誤,意想不到的' ? '在/年月/年月線159
I know next to nothing about php, so I copied and pasted exactly what you typed, with the proper ‘ and .我知道旁邊的PHP一無所知,所以我複製並粘貼您所輸入的文字,適當'和。
Any ideas as to what I’m doing wrong?任何想法,以我在幹什麼事?
Luke, you checked the single quote marks, did you check the angle brackets?盧克,你檢查單引號,你檢查尖括號?
db分貝
Luke // 盧克 / / Apr 23, 2008 at 4:57 pm 2008年4月23號在下午4點57
David,大衛
I checked those as well.我檢查這些的。 I included the angle brackets in my previous post, but they must have been cut out.俺包括尖括號我在以前的職位,但他們必須被切斷了。
I just sent you an email with more specific information.我剛才向您發送一封電子郵件,更具體的信息。
Luke盧克
Thanks for the follow-up.謝謝您的後續行動。 You explained in an email that you’re creating a standalone page you want to theme as if it were part of your blog, but your Wordpress blog is actually in the root of your domain, so there is actually no need to use my workaround.您解釋了一封電子郵件,您要建立一個獨立的網頁中,您要的主題,好像這是一部分,您的博客,但您的WordPress的博客實際上是在根您的域名,所以實際上並不需要使用我的解決方法。
Simply create a “Page” with the content you sent me, tweak the permalink and everything should be fine.只要創建一個“頁”的內容你寄給我,調整永久性一切應該罰款。
If you really must do it this way then try the code without the period before the slash, and if that doesn’t work remove the slash too.如果你真的必須這樣做然後嘗試代碼沒有之前的期間斜線,如果不消除斜線太多。
Let us know how you get on.讓我們知道您上車。
db分貝
I have a site that I need to add the current post to the top of a HTML page.我有一個網站,我需要添加當前帖子頂端的HTML網頁。 Will this work for that?這項工作將是什麼?
What is the code just to bring in the current post?什麼是代碼,將在目前的職位?
Thanks謝謝
Bob, that should work with this code.鮑勃,這應該與此代碼。 You’d need to add the Wordpress loop (see the main index file in your template) and set it to display just one post.你需要添加的WordPress的環(見主要的索引文件在您的範本)並將其設置為顯示一個職位。
db分貝
David,大衛
Im getting the same similar error that Luke reported.林得到同樣的類似的錯誤,盧克報告。
I know that you said the following: “Couple of things to watch out for: if you cut and paste the above code, ensure the quotes are single straight quote marks and the angle brackets are proper code not greater and less than signs.”我知道,你說: “幾件事要留意:如果您剪切和粘貼上述代碼,確保引號是單直引號和尖括號是正確代碼,並沒有更大的不到的跡象。 ”
But I dont see any quote marks or greater/less than signs to correct.但是,我不要看到任何引號或更高/不到跡象正確的。
Any ideas?任何想法?
Kimberley, they’re right there up above…金伯利,他們說得最多有上述...
You have to add this to the source of your page:你必須添加此消息來源的網頁:
< ?php define('WP_USE_THEMES', false); require('./your-wordpress-folder/wp-blog-header.php'); ?> “ ? PHP的界定( ' WP_USE_THEMES ' ,虛假) ;要求( ' 。 /你的WordPress的文件夾/可濕性粉劑,博客, header.php ' ) ; ? ”
You are on an Apache system, yes?您在Apache的系統,是嗎?
db分貝
Okay, I went back tonight to look at the code and my ‘ were slanted… So fixed that.好吧,我今晚回去看看代碼和我的人...所以傾斜固定的。 Im not sure it did anything.林不能確定它沒有任何東西。 Im not getting the Parse error: syntax error, unexpected ‘?’ in /xxxx/xxxx on line 159 error anymore.林沒有得到解析錯誤:語法錯誤,意想不到的' ? '在/年月/年月線159錯誤了。 What’s happening is that the page sort of loads itself, but the images disappear.這是怎麼回事是該網頁排序的負載本身,而是圖像消失。 The link is:這個鏈接是:
http://www.dreamsofmidnight.com/DreamsWeDreampt/index-new.html
[ Yes I know "Dreampt" is spelled wrong. [是的,我知道“ Dreampt ”拼寫錯了。 Just a test folder.只是一個測試文件夾中。 =) ] = ) ]
Hi Kimberley and thanks for your 3 attempts and an email.您好金伯利和感謝您的3企圖和電子郵件。 All got through.所有獲得通過。 Your comments did “stick” it’s just it was night here so I wasn’t at my computer to approve them.您的意見沒有“大棒” ,只是有人在這裡過夜,所以我當時並不在我的計算機到核准。 You should’ve seen a message, however, to say that comments require approval so apologies if that wasn’t apparent.您應該已經看到一條消息,但表示,需要審批的意見,以便道歉,如果這不是很明顯。
db分貝
Kimberley (again) - I mentioned in the post that readers should check that quotes are straight and angle brackets working as html rather than being converted.金伯利(再次) -我剛才在後,讀者應檢查引號的直道和尖括號工作為H TML,而不是轉換。 But, I did take a look at your code and the javascript for rendering your images is pointing to “http://127.0.0.1:1025/js.cgi?pa&r=2401″ that’sa local (ie your machine) rather than the server, so that’s why they’re not showing up because the script needs to be in your root on the site server.但是,我也來看看你的代碼和JavaScript為使您的圖片是指向“ http://127.0.0.1:1025/js.cgi?pa&r=2401 ”這是一個地方(即您的機器) ,而不是服務器,所以這就是為什麼他們沒有出現,因為腳本需要在您的根在該網站的服務器。
That said, what benefits are there to serving images via a script, why not make them absolute and then there’s last chance of things breaking, especially for users running NoScript in their browser!這就是說,什麼好處有在職的圖像通過一個腳本,為什麼不能讓他們絕對的,然後還有最後一次機會的東西打破,特別是對用戶使用NoScript在他們的瀏覽器!
db分貝
I apologize for all the emails.很抱歉,我所有的電子郵件。 I must look like a complete moron.我必須看起來像一個完整的白痴。 However, there was no message showing up on the site, that’s why I thought they weren’t getting through.但是,沒有信息顯示在該網站上,這就是為什麼我認為他們沒有獲得通過。 Sorry about that.我們對此深感抱歉。
I’ll check what you mentioned.我要檢查你所提到的。 And get back to you.和回來給你。
I just did a test comment post Kimberley and once a message has been submitted you should’ve seen a little notice saying it would appear once moderated and now offering you the option to subscribe to the newsfeed.我只是做了測試後評論金伯利和一次的留言已提交你應該看到了什麼通知說,將出現一次審核,現在提供您選擇訂閱通訊社。
db分貝
Hi David,高大衛,
We have a problem when trying to add the .html extension to WP Pages (with a cap P).我們有一個問題,當嘗試添加。的HTML擴展到可濕性粉劑網頁(以市值P ) 。 Do you know if this is possible and how to go about this?你知道,如果這是可能的和如何進行呢?
Thanks謝謝
Sarah莎拉
Sarah, I am pretty sure there is a workaround, but I’ve not yet implemented it and have been persuaded that there is little point as most users are blind to file extensions in URLs these days.莎拉,我肯定有一個解決方法,但是我從來沒有付諸實施,並已說服了,沒有什麼點,大多數用戶都視而不見的文件擴展名在這些天的網址。 There may, just may, be SEO benefits to having the .html, but I’m not sure what those would be.有可能,只要可能,是搜索引擎優化好處有。 html文件,但我不知道那些將。
Have you searched the wordpress forums for an answer?你搜查了WordPress的論壇,一個答案嗎?
Yes, but it seems to be nigh on impossible and not recommended as it involves fiddling with the source code and course there’s future updates to consider.是的,但它似乎是幾乎不可能的,而且上不建議因為它涉及順藤摸瓜的源代碼,當然還有未來的更新考慮。 Nonetheless, if there was a workable solution I would consider it, if only for the benefit of SEO considerations - but again as you say, what are the benefits there?然而,如果有一個可行的解決辦法我認為,如果不僅有利於搜索引擎優化的考慮-但再次正如你所說的那樣,是什麼好處呢?
Actually, there may be hidden SEO benefits to having a few Pages on a site that look to all intents and purposes as if they are actually folder structures rather than individual files, I’m thinking其實,有可能是隱藏搜索引擎優化好處有幾頁的網站上期待著所有意圖和目的,好像他們實際上是文件夾結構,而不是個別的檔案,我想 Google Site Links谷歌網站鏈接
I’m finding way to make these structure, if possible :-我調查的方式,使這些結構,可能的話: -
Eg ->例如-> “
Page structure like this :-網頁結構這樣的: -
domaincom/page1.html
domaincom/page2.html
and Blog Post like this ( as choosing the /%postname%/ for permanent link structure ) :-和博客帖子這樣(如選擇/ % postname % /的永久鏈接結構) : -
domaincom/myblogpost/ domaincom / myblogpost /
domaincom/myblogpost2/ domaincom/myblogpost2 /
…and so on. ...等等。
Would these be possible ?將這些可能呢?
Thanks for your kind help if there is solution.感謝您的實物幫助是否有解決方案。
Datas last blog post..數據最後的博客帖子.. Computer System計算機系統
Data, check out the Wordpress FAQ and forums for assistance on permalinks.數據,檢查了WordPress的常見問題和論壇的永久性援助。
Leave a Comment發表您的評論