1

我已经搜索了几个问题,但仍然遇到问题。我真的很感谢你们的一些专业知识。=)

在我的 WordPress 网站上创建和激活的子主题似乎没有进行任何更改。

我基本上知道零 PHP,但尝试使用 functions.php 而不是 @import,因为它应该是一个更好的加载时间。

这是我的子主题目录 style.css(第一)和 functions.php(第二)中的内容

/*
Theme Name: Quest-Child
Description: No Coward's Quest Child Theme
Author: Jason from No Coward
Author URI: http://www.nocoward.com
Template: quest 
Version: 1.0
*/

/* add padding to site description */
.site-description {
    padding-top: 15px;
    padding-bottom: 30px;
}

.body {
    background: red;
}

/* can be found on "Services" page. Is the first ID within the <p> element */
#cc-m-12571703896 {
    background: blue;
}

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'quest-all-css'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

WordPress 识别子主题并允许我成功激活它。

CSS 中的东西是我试图用来测试我的子主题的东西,这些东西放下了我的改变。什么都没有出现。

同样,我的 PHP 知识为零。基于官方的WordPress“如何创建子主题”,我复制并粘贴了上面的代码,并尝试根据他们的说明填写“父样式”值。

这是我在父主题上看到的内容,我可能将其用于functions.php“父样式”...

// Enqueue required styles
            wp_enqueue_style( 'quest-bootstrap', get_template_directory_uri() . '/assets/plugins/bootstrap/css/bootstrap.min.css' );
            wp_enqueue_style( 'smartmenus', get_template_directory_uri() . '/assets/plugins/smartmenus/addons/bootstrap/jquery.smartmenus.bootstrap.css' );
            wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/plugins/font-awesome/css/font-awesome.min.css' );
            wp_enqueue_style( 'animate-css', get_template_directory_uri() . '/assets/plugins/animate/animate.css' );
            wp_enqueue_style( 'slit-slider', get_template_directory_uri() . '/assets/plugins/FullscreenSlitSlider/css/style.css' );
            wp_enqueue_style( 'colorbox', get_template_directory_uri() . '/assets/plugins/colorbox/colorbox.css' );
            wp_enqueue_style( 'Quest-style', get_stylesheet_uri(), array(
                'quest-bootstrap',
                'smartmenus',
                'font-awesome',
                'animate-css',
                'slit-slider',
                'colorbox'
            ) );

...

// Enqueue required styles
            wp_enqueue_style( 'quest-all-css', get_template_directory_uri() . '/assets/css/plugins-all.min.css' );
            wp_enqueue_style( 'Quest-style', get_stylesheet_uri(), array( 'quest-all-css' ) );

            // Enqueue required scripts
            wp_enqueue_script( 'quest-all-js', get_template_directory_uri() . '/assets/js/quest-and-plugins.js', array(
                'jquery',
                'masonry'
            ) );

我错过了什么?

提前致谢!-杰森

4

1 回答 1

0

我设法解决了这个问题。这是我在帮助论坛上找到的 PHP 代码。我认为“投资组合”位可能是无关紧要的,但它正在发挥作用,所以我将它留在那里以防万一。

<?php
add_action( 'wp_enqueue_scripts', 'quest_child_enqueue_styles' );
function quest_child_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_filter( 'quest_plus_template_content-portfolio', 'quest_child_template_portfolio' );

function quest_child_template_portfolio(){
    return get_stylesheet_directory() . '/content-portfolio.php';
}

对此解决方案的警告:发生了一件奇怪的事情。我添加了一些样式来制作“背景:红色”,这样我就可以测试子主题是否正常工作,尽管删除了那段代码,但它仍然出现。

现在,我将其归结为托管缓慢,但请注意,如果您遵循此解决方案,则会发生这种情况。

希望这对其他人有帮助!=)

杰森

于 2017-07-23T20:19:28.000 回答