gpt4 book ai didi

css - 将自定义页眉和页脚添加到 wordpress 博客

转载 作者:太空宇宙 更新时间:2023-11-03 17:41:08 26 4
gpt4 key购买 nike

这里我有一个网站,tinywolf.uk,我目前正在使用它。主页是一个独立于 wordpress 的静态网站,但网站的博客部分 http://www.tinywolf.uk/blog将由 wordpress 提供支持。

我目前正在使用 25 主题,并且希望在博客的主页中使用页眉和页脚以保持连续性。

到目前为止,我已经创建了一个子主题,然后是一个包含主页标题的新 header.php 文件。这将替换现有的 wordpress header.php 并正确显示,但是,主题其余部分的样式已经消失。我想保持帖子的样式。

如何从 25 主题中调用正确的样式以确保内容(博客文章)的样式正确?

here是我的 child 主题 header.php 的代码

我尝试使用 <link rel="stylesheet" 包含 25 主题的 style.css|虽然这带来了一些格式,但它也破坏了页面的结构。

这是我的 functions.php 的内容:

 <?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/blog/wp-content/themes/twentyfifteen/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/blog/wp-content/themes/twentyfifteen/style.css',
array('parent-style')
);
}
?>

这是我的 child style.css:

    /*
Theme Name: Tiny Theme Child
Theme URI: http://example.com/twenty-fifteen-child/
Description: Twenty Fifteen Child Theme
Author: Joel S
Author URI: http://www.tinywolf.uk/blog
Template: twentyfifteen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fifteen-child
*/

最佳答案

您必须在子主题中链接父主题 style.css。这是来自 codex 的一个很好的例子

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}

codex

关于css - 将自定义页眉和页脚添加到 wordpress 博客,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29062663/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com