0

我有一个简单的 html 页面,我想将其转换为 WordPress 网站。我已经安装了 WordPress 并创建了必要的文件。到目前为止,我一直在寻找有关如何将静态网站转换为 WordPress 但没有运气的教程。大多数教程用户不了解 html 或 php,据我了解,WordPress 具有您必须添加到 html 页面的功能。这是我的 index.php

<!DOCTYPE>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/code.js"></script>
<title></title>
</head>
<body>
<div id="wrapper">
<?php
include "header.php";
?>
<div id="main">
        <div class='nav'><a href="about.php">About</a></div>
        <div class='nav'><a>Events</a></div>
        <div class='nav'><a href="venues.php">Venues</a></div>
        <div class='nav'><a>Gallery</a></div>
        <div class='nav'><a href="arts.php">Arts</a></div>
        <div class='nav'><a href="contact.php">Contact</a></div>
    </div>
<?php
include "footer.php";
?>  
</div>
</body>
</html>

我想将其转换为 WordPress,因此用户可以轻松地从 WordPress 管理面板添加和编辑内容。你们有没有可以推荐的教程来指导我如何做到这一点?如果没有,您将如何将 WordPress 函数添加到我的 index.php 中以使其与 WordPress 兼容。

4

3 回答 3

0

如果您的网站很简单,请尝试使用准系统/入门 WordPress 主题并对其进行自定义以使用您的样式表/javascript 等。

这将比从头开始创建东西更容易和更强大。

还有一些像Theme Matcher这样的工具可以为你做到这一点。

于 2013-11-20T14:36:03.567 回答
0

Here's about the simplest barebones super basic explanation I could come up with..

When writing a Wordpress website I think the first thing you should get is that where-as coding a plain HTML site you have to write the structure of the page and the content.. when you write a Wordpress page you are only writing the structure, all of the content is going to be created in the Wordpress backend user portal.

So to start, remove all the content from your code and your left with this (I'm going to remove the PHP includes and start fresh)

<!DOCTYPE>
<html>
    <head>
        <!-- Include stylesheet -->
        <link rel="stylesheet" type="text/css" href="/style.css" />
        <!-- Include scripts -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript" src="/code.js"></script>

        <!-- Page title / meta -->
        <title></title>
    </head>

    <body>
    <!-- Page container -->
    <div id="wrapper">
        <div id="main">
            <!-- Nav -->
            <div class="nav"></div>
        </div>
    </div>

    </body>
</html>

A wordpress theme is made up of several PHP files and whenever a theme is displayed, typically the index.php file is loaded first so that's where we'll start.

Wordpress themes, most of them, amongst all the PHP files that make up the theme, there will be a header.php file, footer.php file..

So in index.php the first line we write is get_header(); (within php tags of course) This is a Wordpress function that is essentially

I assume your going to want your nav on all pages so you can cut all of this code out of your index file and paste it into header.php

<!DOCTYPE>
<html>
    <head>
        <!-- Include stylesheet -->
        <link rel="stylesheet" type="text/css" href="/style.css" />
        <!-- Include scripts -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript" src="/code.js"></script>

        <!-- Page title / meta -->
        <title></title>
    </head>

    <body>
    <!-- Page container -->
    <div id="wrapper">
        <div id="main">
            <!-- Nav -->
            <div class="nav"></div>
        </div>
    </div>

Back to index.php the second line we'll add is get_footer(); another Wordpress function to get footer.php.

Currently index.php would look like this now..

<?php get_header(); ?>
    </body>
</html>

because everything else is in header.php.. well that closing body and html tag.. those go in footer.php. so your index.php file is going to end up looking like this

<?php get_header();
get_footer(); ?>

Header.php is going to look like this:

<!DOCTYPE>
<html  <?php language_attributes(); ?>>
    <head>
        <!-- Page title / meta -->
        <title><?php wp_title( '|', true, 'right' ); ?></title>
        <?php wp_head(); ?>
    </head>

    <body>
    <!-- Page container -->
    <div id="wrapper">
        <div id="main">
            <!-- Nav -->
            <?php wp_nav_menu(); ?>
        </div>
    </div>

and you know what's in footer.php. As far as those CSS and javascript files, those are going to be in your functions.php file.

Wordpress has LOTS and LOTS of prefab functions that they like for you to use and it would take forever to explain them all. Luckily a lot of that's already been done in the Wordpress Codex. Though it's got a lot to be desired as far as the quality of the documentation in some places in my opinion it is something you should spend a good amount of time reading thru before you start, in order to familiarize yourself with all their functions.

于 2014-09-06T09:45:48.200 回答
0

Wordpress 与基本的静态网站完全不同。所有内容都是数据库驱动的,这意味着您的所有“html 页面”都需要通过仪表板转换为 Wordpress 页面。除非您的网站非常小,否则转换不会是一个快速的过程。

给每个页面一个合理的标题和“slug”,然后将你现有的代码剪切并粘贴到文本编辑器中(你会在网上找到很多帮助)。转换图像会比较麻烦——它们需要通过 WP 媒体加载。链接也需要更改。

要确保您的网站有一个静态首页(即不是博客),请转到设置...阅读...并单击链接。

样式化内容是通过页面模板完成的,这些模板位于称为主题的包中。使用默认主题之一,直到您的内容被传输。他们甚至会有菜单并允许您修改一些样式和标题图像等。查看现有主题中的文件以了解它们是如何工作的。

当您准备好样式时,可以使用其中一个主题作为起点,或者如果您想从头开始,请对空白或入门主题进行一些研究 - 那里有很多。然后我建议你按照教程设计一个 WP 主题...

于 2013-10-09T11:16:44.310 回答