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您大概也得到页脚在您的主题太,所以加入到网页底部结束前body标记
<?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的反应,到目前为止↓
Ben 本 // / / Jun 7, 2007 at 4:16 pm 2007年6月7日在下午4时16分
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?为什么不只是转换为您的所有遗产的页面(一个小规划)到静态网页内的WordPress系统,然后迁往子文件夹到该网站的根? Job done.完成工作。
David Bradley 大卫布拉德利 // / / Jun 7, 2007 at 4:18 pm 2007年6月7日在下午4时18分
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.同时,有可能的原因,您想要保留的一部分,博客在自己的文件夹,并有独立的块在的根源。
deb deb的 // / / Jan 15, 2008 at 2:02 am 2008年1月15日在上午02时02分
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.我想一“感谢,约, seemore ,网页等,并不断打电话给我404页。 how do I stop it?我要如何阻止它呢?
Thanks.l thanks.l
David Bradley 大卫布拉德利 // / / Jan 15, 2008 at 7:16 am 2008年1月15日在上午07时16分
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? deb的,你的意思,你是要创建的静态网页在WordPress所谓的从网页,或者您作出独立的页面,但不想让他们使用可湿性粉剂范本吗? Please clarify and someone here might be able to assist.请澄清,并有人在这里也许能够提供协助。
First thought, did you double check the links you’re using?第一的思想,你仔细检查链接,您使用的呢?
db分贝
deb deb的 // / / Jan 17, 2008 at 6:57 am 2008年1月17日在上午06时57分
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.另外,我创建了一个文件夹中的所谓“感谢的权利,在域的根。 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.请帮帮忙。
David Bradley 大卫布拉德利 // / / Jan 17, 2008 at 7:31 am 2008年1月17日在上午07时31分
Deb, that is very odd. deb的,这是非常奇怪的。 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分贝
deb deb的 // / / Jan 18, 2008 at 3:37 am 2008年1月18日在上午03时37分
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 1 sista不能waisting三天试图弄清楚这高科技的东西
Thanks for all your help though.感谢所有您的帮助,虽然。
DG危险品
TATHAGAT tathagat // / / Feb 2, 2008 at 8:26 am 2008年2月2日在上午8时26分
please send the process of making html page请在发送的过程中作出的HTML网页
David Bradley 大卫布拉德利 // / / Feb 2, 2008 at 9:29 am 2008年2月2日在上午09时29分
Send it where Tathagat?它传送的地方tathagat ? It’s right here.它的权利在这里。 On the page在网页上
db分贝
Ariela ariela // / / Mar 6, 2008 at 10:01 pm 2008年3月6日在下午10时01分
Hey,嗨,
I think I followed your directions exactly, but nothing is showing up on the page.我想我遵循您的方向,正是,但没有显示在网页上。
Ariela ariela
David Bradley 大卫布拉德利 // / / Mar 7, 2008 at 7:40 am 2008年3月7日在上午07时40分
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的” (可与。 htm , 。 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分贝
Ariela ariela // / / Mar 7, 2008 at 7:50 am 2008年3月7日在上午07时50分
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!感谢,虽然!
David Bradley 大卫布拉德利 // / / Mar 7, 2008 at 10:44 am 2008年3月7日在上午10时44分
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分贝
Ariela ariela // / / Mar 8, 2008 at 8:17 am 2008年3月8日在上午8时17分
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!) (和感谢为恭维上的照片-我会告诉摄影师知道! )
Scott 斯科特 // / / Apr 14, 2008 at 6:00 am 2008年4月14日在上午06点
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解析错误:语法错误,意想不到的' ? '在/为XXXX / XXXX的就行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?任何想法,以什么,我做的不对呢?
David Bradley 大卫布拉德利 // / / Apr 23, 2008 at 7:43 am 2008年4月23日在上午07时43分
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包括角括弧我在以前的职位,但他们必须被切断。
I just sent you an email with more specific information.我刚才您发送了一封电子邮件,与更具体的信息。
Luke路加福音
David Bradley 大卫布拉德利 // / / Apr 23, 2008 at 5:09 pm 2008年4月23日在下午5时09分
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分贝
Bob O'Haver 鲍勃o'haver // / / May 16, 2008 at 6:29 pm 2008年5月16日在下午6时29分
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谢谢
David Bradley 大卫布拉德利 // / / May 16, 2008 at 6:44 pm 2008年5月16日在下午6时44分
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分贝
Kimberley 金伯利 // / / May 18, 2008 at 8:27 pm 2008年5月18日在下午8时27分
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?任何想法?
David Bradley 大卫布拉德利 // / / May 19, 2008 at 8:31 am 2008年5月19日在上午8时31分
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分贝
Kimberley 金伯利 // / / May 20, 2008 at 1:45 am 2008年5月20日在上午01时45分
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.即时通讯得不到解析错误:语法错误,意想不到的' ? '在/为XXXX / XXXX的就行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 http://www.dreamsofmidnight.com/dreamswedreampt/index-new.html
[ Yes I know "Dreampt" is spelled wrong. [是我知道“ dreampt ”是拼写错误的。 Just a test folder.只是一个测试文件夹。 =) ] = ) ]
David Bradley 大卫布拉德利 // / / May 20, 2008 at 7:45 am 2008年5月20日在上午07时45分
Hi Kimberley and thanks for your 3 attempts and an email.喜的金伯利和感谢您对三的企图和电子邮件。 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分贝
David Bradley 大卫布拉德利 // / / May 20, 2008 at 7:47 am 2008年5月20日在上午07时47分
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分贝
Kimberley 金伯利 // / / May 21, 2008 at 4:09 am 2008年5月21日在上午04时09分
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.和回到你这里。
David Bradley 大卫布拉德利 // / / May 21, 2008 at 7:50 am 2008年5月21日在上午07时50分
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分贝
Sarah 莎拉。 // / / Jun 18, 2008 at 4:12 pm 2008年6月18日在下午4时12分
Hi David,喜国宝,
We have a problem when trying to add the .html extension to WP Pages (with a cap P).我们有一个问题,当尝试添加的。 html扩建可湿性粉剂的页面(与上限,规划) 。 Do you know if this is possible and how to go about this?你知不知道如果这是可能的,以及如何去对这个?
Thanks谢谢
Sarah莎拉。
David Bradley 大卫布拉德利 // / / Jun 18, 2008 at 5:47 pm 2008年6月18日在下午5时47分
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论坛,一个答案?
Sarah 莎拉。 // / / Jun 18, 2008 at 6:35 pm 2008年6月18日在下午6时35分
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.是的,但它似乎是对几乎是不可能的和不推荐,因为它涉及fiddling与源代码和,当然还有未来的更新考虑。 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?不过,如果有一个可行的解决办法,我会考虑,如果不仅有利于徐考虑-但再次正如你所说,有什么好处呢?
David Bradley 大卫布拉德利 // / / Jun 18, 2008 at 7:15 pm 2008年6月18日晚上7时15分
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 Google网站的链接
Data 数据 // / / Jun 27, 2008 at 9:15 pm 2008年6月27日在下午9点15分
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电脑系统
David Bradley 大卫布拉德利 // / / Jun 29, 2008 at 8:19 pm 2008年6月29日在下午8时19分
Data, check out the Wordpress FAQ and forums for assistance on permalinks.数据,检查出的WordPress的常见问题和论坛的援助永久。
Leave a Comment留下意见