css - how to add functions to my function.php using a child theme?

I am trying to add functions to my child theme function.php file but each time i try the site crashes. I dont know how t

I am trying to add functions to my child theme function.php file but each time i try the site crashes. I dont know how to add the functions the right way.

<?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {

        $parent_style = 'PRANAYAMA_YOGA_THEME_VERSION'; // 

        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')
        );
    }

I was using this link [/][1], and pasted this code inside my function.php file.

// Custom Function to Include
function my_favicon_link() {
    echo <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />' . "\n";
}
add_action( 'wp_head', 'my_favicon_link' );

How can I do this ?

Thanks in Advance

I am trying to add functions to my child theme function.php file but each time i try the site crashes. I dont know how to add the functions the right way.

<?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {

        $parent_style = 'PRANAYAMA_YOGA_THEME_VERSION'; // 

        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')
        );
    }

I was using this link [https://developer.wordpress/themes/advanced-topics/child-themes/][1], and pasted this code inside my function.php file.

// Custom Function to Include
function my_favicon_link() {
    echo <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />' . "\n";
}
add_action( 'wp_head', 'my_favicon_link' );

How can I do this ?

Thanks in Advance

Share Improve this question asked Aug 12, 2019 at 8:59 davidhlynsdavidhlyns 178 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The site crashes, because you have a typo in that code. You're missing an apostrophe at the beginning of the string:

// Custom Function to Include
function my_favicon_link() {
    echo <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />' . "\n";
         ^ missing apostrophe
}
add_action( 'wp_head', 'my_favicon_link' );

Here's the fixed version:

// Custom Function to Include
function my_favicon_link() {
    echo '<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />' . "\n";
}
add_action( 'wp_head', 'my_favicon_link' );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745250248a4618636.html

相关推荐

  • css - how to add functions to my function.php using a child theme?

    I am trying to add functions to my child theme function.php file but each time i try the site crashes. I dont know how t

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信