将HTML页面添加到WordPress中

时间:2010-08-16 04:29:44

标签: wordpress wordpress-theming

在我的网站中,我正在转换为WordPress CMS主题,有7个菜单选项可用于单独的html页面。

我的问题是,将这7个html页面放入我的WordPress CMS主题的最佳方法是什么,即是否有后端意味着我是否直接将这些单独的页面添加为WordPress管理员?

我目前的菜单选项设置如下:

<li><a href="index.html" class="topm currentMenu nosub">Home</a></li>
<li><a href="about-us.html" class="topm nosub">About Us</a></li>

此外,如何在WordPress中将菜单链接到我的页面?

由于

3 个答案:

答案 0 :(得分:1)

You can convert your html pages to wordpress pages by using template pages for your 
each menus.Before that create files name header.php,index.php,sidebar.php,footer.php
,style.css in your theme folder.Then follow the below steps:

1. Include all the contents of your home.html upto your menu creation like this in your 
   header.php:


<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Course</title>
</head>
<body>
<div id="wrapper">
    <div class="w1">
        <div class="w2">
            <!-- header -->
            <header id="header">
                <div class="line"></div>
                <!-- logo -->
                <h1 class="logo"><a href="#">Company Logo</a></h1>
                <!-- main nav -->
                <nav id="nav">
                <!--**replace your menu listings by the given below codes**-->
                    <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
                </nav>
                <div class="clear"></div>
                </header>   
<?php wp_head(); ?>

2. In index.php, include the body contents of home.html
   in between the below codes:


<?php

/**

* Template Name: home
*

* Selectable from a dropdown menu on the edit page screen.

*/

?>

<?php get_header(); ?>

//body contents of home page

<?php get_footer(); ?>

3.Likewise, you can include as much menu you want.Just by changing like this for about 
  us:

<?php

/**

* Template Name: aboutus
*

* Selectable from a dropdown menu on the edit page screen.

*/

?>

<?php get_header(); ?>

//body contents of aboutus page

<?php get_footer(); ?>



4. If you have any footer contents(contents needed to display at the bottom of all 
  pages).Then include the contents in footer.php.If no contents is there,then 
  also simply create a file named footer.php.

5. Include the side contents to sidebar.php(contents to be displayed in right side of 
   the page).If no side contents are there.Then,simply create sidebar.php.

5. style.css,containing the css for all pages.

6.After creating all html files to .php files.Open the admin dashboard of your website.
  In that open,Pages->Add new.In Add New Page,Enter the menu name(Home) in title and in 
  right side,click the Template dropdown and select the template name(home) and click 
  Publish button.

7.Likewise,create pages for all menus by giving title and selecting template name from 
  the template dropdown and click publish button after selecting.

8.Then,open Appearance->Menus.Then Menus page will open,in that on left side corner,you
  will see Pages tag,click view all and check all the pages you want to display as 
  menus in your website and click Add to Menu button.

9.Then,the selected pages will be shown on right side,in bottom you will see Save Menu 
  button,click it.

8.After finishing all,on top left corner click on the website name and see the website 
  with the following menus and their corresponding pages.

答案 1 :(得分:0)

澄清你的问题。你想在WordPress管理员中编辑那些html页面吗?你不能。页面必须是WP后端的一部分,并且驻留在数据库中,以便在编辑器中进行编辑。

如果您只想在WP页面的菜单中链接这些页面,则必须在header.php(或其他页面模板)中将它们硬编码为链接,因为wp_list_pages无法调用静态html页面或其他WP php函数。

答案 2 :(得分:0)

  

“...请使用about-us.html页面源代码   我在Dreamweaver中创建了,进入   WP-Admin,Pages,添加新页面和删除   将html代码放入html选项卡中   代码......“

可以 这样做。但请勿使用&lt; code&gt;&lt; / code&gt;标签(或页面将显示您的“原始”HTML。)

它应该是这样的:

  • 创建新页面,标题为“关于”。
  • 将原始“about.html”的&lt; body&gt;&lt; / body&gt; 标记内的源代码复制并粘贴到html编辑器中(确保您使用的是“html”) “模式 - 不是”视觉“。)

注意:提交页面时,WP会剥离&lt; script&gt; 标记(以及其他一些标记)。)

  • 您的“菜单选项”(我认为这是您的导航?)不能指向“about.html”,因为它可以作为动态的WP控制页面。无论如何,您的新“关于”页面可能会出现在导航中。
相关问题