【问题标题】:placing custom wordpress file in child theme folder and getting get_header and get_footer to work将自定义 wordpress 文件放在子主题文件夹中并让 get_header 和 get_footer 工作
【发布时间】:2020-01-30 01:49:02
【问题描述】:

更新:

我最初安装了二十二作为我的主题。我做的第一件事是创建一个子主题,然后安装插件页眉和页脚。我使用这个插件来创建我的页眉和页脚。

一个教程说将自定义模板放在子主题目录中。当我这样做时,我必须指出表单操作的正确路径:

../wp-content/themes/twentytwelve-child/swaghome.php

当我这样做时,找到了页面,但 get_header() 和 get_footer() 不起作用。如果我将文件放在 public_html 中,然后将操作更改为:

swaghome.php

一切正常。

如何将我的自定义页面保留在我的子主题文件夹中,并且 get_header() 和 get_footer() 仍然有效?

这里是 swaghome.php

<?php /* Template Name: swaghome */ ?>

<?php  get_header(); ?>

<div id="primary" class="site-content">
    <div id="content" role="main">

        <?php   


        if(isset($_POST["place"]) && 
           strcmp($_POST("place","foot"))==0)$place="foot";
        else if(isset($_POST["place"]) && 
           strcmp($_POST("place","involved"))==0)$place="involved";
        else $place="home";

        echo $place;

        ?>



    </div><!-- #content -->
</div><!-- #primary -->


<?php get_footer(); ?>

这是来自子主题的 style.css:

/*
Theme Name: Twenty Twelve Child
Theme URI: https://wordpress.org/themes/twentytwelve/
Template: twentytwelve
Author: the WordPress team
Author URI: https://wordpress.org/
Description: The 2012 theme for WordPress is a fully responsive theme that looks great on any device. Features include a front page template with its own widgets, an optional display font, styling for post formats on both index and single views, and an optional no-sidebar page template. Make it yours with a custom menu, header image, and background.
Tags: blog,one-column,two-columns,right-sidebar,custom-background,custom-header,custom-menu,editor-style,featured-images,flexible-header,footer-widgets,full-width-template,microformats,post-formats,rtl-language-support,sticky-post,theme-options,translation-ready
Version: 3.0.1568336488
Updated: 2019-09-13 01:01:28

*/

【问题讨论】:

    标签: wordpress wordpress-theming


    【解决方案1】:

    好的,如果您通过教程创建子主题,那么您可以将模板与父模板一起使用。如果您没有子主题页眉和页脚,则它们都来自父主题。

    【讨论】:

    • 回答没有帮助。能详细解释一下吗?
    • 请在子主题中显示您的 style.css 以及它是什么 swaghome?模板?
    • style.css 只是 css,所以这个问题并不真正需要。 swaghome.php 只是一个简单的自定义模板
    • 在 style.css main 中,正确的标题(评论)告诉 WordPress 什么是子主题。
    • 查看问题,添加的文件
    猜你喜欢
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-17
    • 1970-01-01
    • 2019-03-17
    • 2013-03-22
    相关资源
    最近更新 更多