代码之家  ›  专栏  ›  技术社区  ›  AnchovyLegend

Wordpress子主题,创建自定义php模板页

  •  0
  • AnchovyLegend  · 技术社区  · 7 年前

    *-content.php 结构,例如: foo-content.php .

    我创建了我想开发的自定义页。然而,当访问url时,我得到了一个空白的白色页面。我很难理解这是为什么。

    另外,我试着转到wordpress admin并在admin中创建页面,使其与我创建的文件名相匹配 my.domain.com/foo

    我很感激你的建议。

    3 回复  |  直到 7 年前
        1
  •  0
  •   Xhynk    7 年前

    如果您特别需要制作页面模板,请阅读 Page Template Files 主题开发人员手册的一节。

    <?php
    /*
        Template Name: Foo Content
    */
    // Your code here
    

    然后进入wp管理员创建一个新页面,并在右侧的模板选择器中选择Foo内容页面模板。

    你也可以看看 Template Hierarchy

        2
  •  0
  •   Danielle Maria Ali    7 年前

    是否包含index.php文件?没有它,你的网站将没有起点,你不会看到任何错误,但只是一个空白页。我会确保你有一个index.php在里面。它应包含:

    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    
        3
  •  0
  •   Johannes    7 年前

    推荐文章