php - 带有我模板的页眉/侧边栏/页脚的 Wordpress 空白页

标签 php css wordpress html

如何在类似 public_html/test1 的目录中创建页面 有一个带有 header/sidebar/footer空白页我的实际模板
我只能看到标题,没有侧边栏,没有内容(内容我的意思是“你好。”)。 我正在使用二十一十四模板。

这是我正在使用的 php 代码:

<?php
/*
* Template Name: My own page!
* Description: I made a page!
*/ 
require (dirname(dirname( __FILE__ )).'/wp-load.php');
get_header();   
get_sidebar();
?>
Hello.

注意:如果我删除 the_content(); get_footer(); , 然后标题只出现但没有格式。

非常感谢任何帮助

最佳答案

内容没有出现,因为您的模板中没有循环。请将此代码添加到您的模板中,并将您的模板文件移动到 twentyfourteen 主题中的“page-templates”文件夹。

<?php
/*
* Template Name: My own page!
* Description: I made a page!
*/

get_header(); ?>

<div id="main-content" class="main-content">

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">
            <?php
                // Start the Loop.
                while ( have_posts() ) : the_post();

                    // Include the page content template.
                    get_template_part( 'content', 'page' );

                endwhile;
            ?>
        </div><!-- #content -->
    </div><!-- #primary -->
</div><!-- #main-content -->

<?php
get_sidebar();
get_footer();

附注如果您愿意,可以删除 div。

关于php - 带有我模板的页眉/侧边栏/页脚的 Wordpress 空白页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25880337/

相关文章:

php - 类似于 CLOS 的 PHP 对象模型

php - 从数据库表中获取值到选择框中

PHP 水印 - Zubrag

html - 如何在 CSS 中旋转背景?

css - Wordpress 插件 CSS 顺序

php - 邮政编码下方的内容无效

php - 从 URL 获取变量

javascript - Firefox 未在切换的 div 中加载 wuFoo 表单

html - 将样式应用于具有特定值的孙子的祖 parent

php - 如何在 Wordpress 管理小部件中包含 javascript 文件