简体   繁体   English

将HTML模板与Wordpress PHP文件混合使用

[英]Mixing HTML Template with Wordpress PHP File

I'm trying to create a Wordpress template on one of my website pages, http://www.windowblindshadeshutters.com/blog/ . 我正在尝试在我的一个网站页面上创建一个Wordpress模板, http://www.windowblindshadeshutters.com/blog/ The blog is now created, but I want to keep our original existing HTML template header so that it appears like the rest of the website, and then have the Wordpress template PHP file appear as the content on this page. 现在创建了博客,但我希望保留原始的现有HTML模板标题,使其看起来像网站的其余部分,然后将Wordpress模板PHP文件显示为此页面上的内容。

I started off just copying and pasting our original HTML header code in the top of the Wordpress PHP file, but it doesn't seem to be working right. 我开始只是复制并粘贴Wordpress PHP文件顶部的原始HTML标题代码,但它似乎没有正常工作。 I'm also wanting to include a doctype at the top, just like the original header, but I'm thinking that you shouldn't do this in a PHP file. 我也想在顶部包含一个doctype,就像原始标题一样,但我认为你不应该在PHP文件中这样做。 My desired result would also require me to mix the original css file with the Wordpress css file, and it just seems like it's not working correctly. 我想要的结果还需要我将原始的css文件与Wordpress css文件混合,看起来它似乎无法正常工作。

So my question is, "How do I use an existing HTML header (that contains all of the original CSS styling) and insert it into a Wordpress theme effeciently?" 所以我的问题是,“我如何使用现有的HTML标题(包含所有原始CSS样式)并将其有效地插入到Wordpress主题中?” Is it as easy as cutting and pasting code, transferring the CSS files, etc? 它是否像剪切和粘贴代码,传输CSS文件等一样简单?

The original website header can be found at the root domain of the link above. 原始网站标题可以在上面链接的根域中找到。

I'm not entirely sure if I got your question right, so I stand to be corrected: You are intending bring some HTML elements in your main site's header into the blog section's header which is residing in a Wordpress install on your server right? 我不完全确定我的问题是否正确,所以我有待纠正:您打算将主网站标题中的一些HTML元素放入博客部分的标题中,该标题位于服务器上的Wordpress安装中吗?

Well, you're right in the sense that it is copy and paste effort, but I think the more important questions are: from which point on you should be adding those HTML elements in the header.php and what are the things that can or cannot be changed / deleted. 嗯,你是正确的,它是复制和粘贴的努力,但我认为更重要的问题是:从哪一点你应该在header.php中添加那些HTML元素,以及可以做什么或者无法更改/删除。

Perhaps a better way to go about this would be for me to tell you the standard things in a header.php and break it down. 也许更好的方法是让我告诉你header.php中的标准内容并将其分解。

<!--the mark up-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--the mark up-->

<head>

<!--meta-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!--meta-->

<!--document title-->
<title><?php bloginfo('name');?></title>
<!--document title-->

<!--links to scripts and stylesheets-->
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url');?>/style.css" />
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-1.6.1.min.js"></script>
<!--links to scripts and stylesheets-->

</head>

<?php wp_head();?> <!--do not remove-->

THE MARK UP 标记

Okay, so the markup definition in the Doctype is definitely needed in the header.php otherwise the Wordpress theme will not know what it's marked up as. 好的,所以在header.php中肯定需要Doctype中的标记定义,否则Wordpress主题将不知道它被标记为什么。 Moreover, the blog section is a Wordpress install on a sub-directory right? 而且,博客部分是一个WordPress安装在子目录上吗? Chances are is that it is so it's not gonna be able to grab any information in the root directory where your actual main site is residing in. 有可能它是如此,它将无法获取您的实际主站点所在的根目录中的任何信息。

META META

You can copy the meta description tags or keywords tags from your actual main site and add them to the header.php 您可以从实际主站点复制元描述标签或关键字标签,并将它们添加到header.php中

DOCUMENT TITLE 文件名

You can either choose to hard code and enter the title on the code level or change the blog title in the Wordpress Dashboard and leave it as <?php bloginfo('name');?> . 您可以选择硬编码并在代码级别输入标题, 也可以更改Wordpress仪表板中的博客标题,并将其保留为<?php bloginfo('name');?> This PHP tag automatically draws whatever is defined as the blog title in the Wordpress Dashboard as the document title. 此PHP标记自动绘制Wordpress仪表板中定义为博客标题的任何内容作为文档标题。 So if the blog title is different from your actual site's title then you will most probably see a discrepancy in that. 因此,如果博客标题与您的实际网站标题不同,那么您很可能会看到其中的差异。

LINKS TO SCRIPTS AND STYLESHEETS 与脚本和风格的链接

If you wish to include the stylesheet from your actual main site that is residing in the root directory, then you will have to change the href to an absolute link that goes there. 如果您希望包含驻留在根目录中的实际主站点的样式表,则必须将href更改为绝对链接。 For eg it will look something like <link rel="stylesheet" type="text/css" href="http://www.yourdomain.com/css/style.css" /> rather than <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url');?>/style.css" /> which only links to within your Wordpress install's theme directory. 例如,它看起来像<link rel="stylesheet" type="text/css" href="http://www.yourdomain.com/css/style.css" />而不是<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url');?>/style.css" />只链接到Wordpress安装的主题目录中。 So suppose that you link that external stylesheet from the main site's location to the header.php by means of the method I just mentioned, you can go ahead and paste the necessary HTML content from your actual site's header and the styles should come out right - as long as the classes or ids remain the same. 因此,假设您通过我刚才提到的方法将外部样式表从主站点的位置链接到header.php,您可以继续从实际站点的标题中粘贴必要的HTML内容,样式应该正确 - 只要类或ID保持不变。

ADD REQUIRED HTML CONTENT 添加所需的HTML内容

So once that is all done, go ahead and add any required HTML content from your actual site's header after the <?php wp_head();?> tag. 因此,一旦完成所有操作,请继续在<?php wp_head();?>标记之后添加实际网站标题中的所有必需HTML内容。 You can add it anywhere you want to and in any order you like to. 您可以按照自己喜欢的任何顺序添加它。 Just be sure not to mess or overwrite any default template codes that the theme has. 请确保不要弄乱或覆盖主题所具有的任何默认模板代码。

Hope this has answered your question somehow. 希望这已经以某种方式回答了你的问题。

You have to edit the header.php file. 您必须编辑header.php文件。

After you finished the <header> section, you can start adding the page header. 完成<header>部分后,您可以开始添加页眉。

This will be included in all WP pages / posts. 这将包含在所有WP页面/帖子中。

If you add wrapper start tags in haeder.php , don't forget to end them in footer.php 如果你在haeder.php添加包装器开始标签,不要忘记在footer.php结束它们

Read more about this here: http://codex.wordpress.org/Designing_Headers 在这里阅读更多相关信息: http//codex.wordpress.org/Designing_Headers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM