• Resolved nopewhy

    (@nopewhy)


    Hello.

    I’ve set up a child-theme on top of a vanilla storefront theme some time ago. It also includes a functions.php to enque the functions from the parent theme and add some google fonts. Everything worked fine for quite a few days.
    Now I tried to add some new code to the end of the child’s functions.php, updated it. Didn’t work, well, I uploaded the old version from before again – that’s when everything went south.
    Even though I didn’t change a bit (as I restored the well working functions.php from before, no new code added), the code to include my google fonts is just being plastered at the beginning of the HTML, even before “<doctype….” and thus being sprayed on top of the page.
    I guess the part of the function, that should take it and add it to the functions, doesn’t work anymore.

    Unfortunately I can’t give you a link, but I guess the screenshot tells it all.

    That’s my child theme’s functions.php:

    <?php
    function my_theme_enqueue_styles() {
    
        $parent_style = 'storefront-style'; // 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' );
    ?>
    
    // adds google fonts to the theme
    add_action( ‘wp_enqueue_scripts’, ‘awts_replace_font’, 999 );
    function awts_replace_font() {
    wp_dequeue_style( ‘storefront-fonts’ );
    wp_enqueue_style( ‘raleway’, ‘//fonts.googleapis.com/css?family=Raleway:400,500,600,700,80’ );
    }

    At this point I am not sure whether I am tripping, really did change something without even noticing (huh?) or whether uploading and downloading with filezilla could wreck/alter a php-file.
    (I am aware that this is the general board, but I guess my question is not really specific for storefront but probably rather broad, so I hope this is the right place.)

    On the site:
    https://prnt.sc/l2bhum
    Source:
    https://prnt.sc/l2bics

    Concerning the weird special characters: I feared there might be a conflict with the way notepad++ or windows notepad save php files, so I tried to save the same code on the other program, but the only thing that changed was that there were no special charactes displayed on top of my page anymore, but the error persisted.

    • This topic was modified 6 years, 1 month ago by nopewhy.
    • This topic was modified 6 years, 1 month ago by nopewhy.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    After the “add_action”, you close PHP with a ?> so the rest of the file is treated as HTML. Delete that line.

    Thread Starter nopewhy

    (@nopewhy)

    Oh.my.gosh.
    Thank you so much!

    I have no idea how this error could get into my functions.php-backup.
    I guess I must have somehow really switched my backup with an old, experimental functions.php I was trying the font-including on?

    Anyhow, you saved my night! I’m most grateful.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Child-theme’s functions.php suddenly stopped working, displays function as text’ is closed to new replies.