首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将自定义wordpress文件放入子主题文件夹,并让get_header和get_footer正常工作

将自定义wordpress文件放入子主题文件夹,并让get_header和get_footer正常工作
EN

Stack Overflow用户
提问于 2019-10-01 02:36:32
回答 1查看 131关注 0票数 0

更新:

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

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

代码语言:javascript
复制
../wp-content/themes/twentytwelve-child/swaghome.php

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

代码语言:javascript
复制
swaghome.php

一切正常。

如何在保留我的子主题文件夹中的自定义页面的同时,仍然让get_header()和get_footer()工作?

这是swaghome.php

代码语言:javascript
复制
<?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:

代码语言:javascript
复制
/*
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

*/
EN

回答 1

Stack Overflow用户

发布于 2019-10-01 03:00:37

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

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58173438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档