网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   WordPress (https://www.0058.net/forumdisplay.php?f=68)
-   -   WordPress 留言板 (https://www.0058.net/showthread.php?t=4189)

topvip 2010-08-30 09:12 PM

WordPress 留言板
 
留言板包括两个部分, 即话题和评论. 话题部分可以是静态内容, 而评论需要借用 WordPress 的. 我们可以创建一个 page, 以 page 内容作为留言板话题, 并将该页面设为网站首页, 其他不可用链接全部转跳首页.


制作这个 WordPress 主题, 我们只需要 3 个文件: style.css, index.php, comments.php. 当 page.php 文件不存在时, page 会调用 index.php 作为它的模板. 以下是我的 index.php 文件内容.
Code:

<?php get_header(); ?>
 
留言板的话题和相关内容写在这里...
 
<?php
        if(have_posts()) {
                the_post();
                comments_template('', true);
        }
 
        get_footer();
?>

可以看出, 还是要判断一下文章是否存在的, 倒不是为了显示文章内容, 这是为了给评论提供 $post 变量, 以便显示对应的评论. 留言板主题的其余部分与一般主题无异, 按需修改即可.

最后我们还需要为 WordPress 设置一下首页的映射, 进入后台 Setting -> Reading, Front page displays 选择 A static page, 并将 Front page 设为之前创建的 page.


All times are GMT +8. The time now is 02:15 PM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.