我使用了足够多的主题,我想以codex中建议的方式创建一个子主题,即使用wp\\U enqueue\\U样式。我是按照解释的方式做的,但左边距现在更像是向右缩进。在我看来,似乎有一些样式表加载问题。
我创造了风格。css和函数。php在子主题文件夹中。在父主题文件夹中有1个样式。css文件和“/css”目录中的11个css文件。
我尝试了很多事情,但都做不好。下面是我如何尝试加载父主题样式表。
<?php
add_action( \'wp_enqueue_scripts\', \'my_theme_enqueue_styles\' );
function my_theme_enqueue_styles() {
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/style.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/admin-options.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/base.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/colors.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/box-modules.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/approach.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/comment.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/fonts.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/layout-fluid.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/normalize.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/post-format.css\' );
wp_enqueue_style( \'styles\', get_template_directory_uri() . \'/css/ua.css\' );
}
?>
我使用“style”作为第一个参数,因为在函数中。php中的父主题i.i足够了,我有以下代码,(我在代码行前面放了一行带箭头的------------------------------->)-
/**
*
*
*/
if ( !function_exists( "enough_enqueue_scripts_styles" ) ) {
function enough_enqueue_scripts_styles() {
global $is_IE, $enough_version;
$enough_csses = array( "css/normalize.css", "genericons/genericons.css", "css/fonts.css", "css/box-modules.css", "css/comment.css", "css/ua.css", "css/colors.css", "css/base.css", "css/layout-fluid.css", "css/post-format.css", "css/approach.css" );
foreach ( $enough_csses as $ecnough_css_path ) {
if ( file_exists( trailingslashit( get_stylesheet_directory() ) . $ecnough_css_path ) ) {
wp_enqueue_style( \'enough_\' . basename( $ecnough_css_path, \'.css\' ), trailingslashit( get_stylesheet_directory_uri() ) . $ecnough_css_path, array(), $enough_version );
} else {
wp_enqueue_style( \'enough_\' . basename( $ecnough_css_path, \'.css\' ), trailingslashit( get_template_directory_uri() ) . $ecnough_css_path, array(), $enough_version );
}
}
----------->wp_enqueue_style( \'styles\', get_stylesheet_uri(), array( \'enough_approach\' ), $enough_version );
$gallery_style = enough_gallerys_css();
wp_add_inline_style( \'styles\', $gallery_style );
wp_enqueue_style( \'enough-web-font\', apply_filters( \'enough_web_font\', \'//fonts.googleapis.com/css?family=Ubuntu:400,700\' ) );
wp_enqueue_script( \'jquery\' );
wp_enqueue_script( \'comment-reply\' );
if ( $is_IE ) {
wp_register_script( \'html5shiv\', get_template_directory_uri() . \'/inc/html5shiv.js\', array(), \'3\', false );
wp_enqueue_script( \'html5shiv\' );
}
}
}
我是否需要在子主题中创建所有css文件?或者我只能有一个css文件,即样式。子主题中的css?正确的做法是什么?
Edited this way
<?php
add_action( \'wp_enqueue_scripts\', \'my_theme_enqueue_styles\' );
function my_theme_enqueue_styles() {
wp_enqueue_style( \'parent-style\', get_template_directory_uri() . \'/style.css\' );
wp_enqueue_style( \'style1\', get_template_directory_uri() . \'/css/admin-options.css\' );
wp_enqueue_style( \'style2\', get_template_directory_uri() . \'/css/base.css\' );
wp_enqueue_style( \'style3\', get_template_directory_uri() . \'/css/colors.css\' );
wp_enqueue_style( \'style4\', get_template_directory_uri() . \'/css/box-modules.css\' );
wp_enqueue_style( \'style5\', get_template_directory_uri() . \'/css/approach.css\' );
wp_enqueue_style( \'style6\', get_template_directory_uri() . \'/css/comment.css\' );
wp_enqueue_style( \'style7\', get_template_directory_uri() . \'/css/fonts.css\' );
wp_enqueue_style( \'style8\', get_template_directory_uri() . \'/css/layout-fluid.css\' );
wp_enqueue_style( \'style9\', get_template_directory_uri() . \'/css/normalize.css\' );
wp_enqueue_style( \'style10\', get_template_directory_uri() . \'/css/post-format.css\' );
wp_enqueue_style( \'style11\', get_template_directory_uri() . \'/css/ua.css\' );
}
?>
这里是
style.css 在子主题中
/*
Theme Name: Enough Child
Theme URI: http://www.tenman.info/wp3/enough/
Description: Satisfied enough necessary minimum structure Responsive Theme. HTML5 , Supports Post Format Archives , You can select your favorite Post Format
Author: Tenman
Author URI: http://www.tenman.info/wp3/
Version: 1.22
Tags: two-columns,custom-colors, custom-header, custom-background, custom-menu, editor-style, threaded-comments, sticky-post, flexible-header
Template: enough
Text Domain: enough-child
License: GNU General Public License v2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
图像_