• Hi there,

    I am running a site with a storefront child theme and whenever I add code to the funtions.php file it results in:Parse error: syntax error…storefront-child/functions.php on line 16

    I can fix this but why won’t it work?

    The code I was trying to add is below – I am adding this code above the
    // END ENQUEUE PARENT ACTION;

    and have used the plugin ‘Child Theme configurator by Lilaea

    any help would be greatly appreciated!

    Mark
    +++++++++++++++++

    <?php
    /**
     * Adds a top bar to Storefront, before the header.
     */
    function storefront_add_topbar() {
        ?>
        <div id="topbar">
            <div class="col-full">
                <p>Your text here</p>
            </div>
        </div>
        <?php
    }
    add_action( 'storefront_before_header', 'storefront_add_topbar' );
Viewing 5 replies - 1 through 5 (of 5 total)
  • Are you adding this to the bottom of your functions.php file?
    If so, there should be no space underneath the last line of code…
    add_action( 'storefront_before_header', 'storefront_add_topbar' );
    …and no closing tag “?>

    Put it underneath “// END ENQUEUE PARENT ACTION;” with a space between.

    And if this is in your functions.php…
    +++++++++++++++++
    …remove it.

    Thread Starter Markb

    (@terasolar)

    Hi there,

    Thanks for getting back.

    Can you confirm that this is correct?

    endif;
    add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css' );
    
    <?php
    /**
    * Adds a top bar to Storefront, before the header.
    */
    function storefront_add_topbar() {
    ?>
    <div id="topbar">
    <div class="col-full">
    <p>Your text here</p>
    </div>
    </div>
    <?php
    }
    add_action( 'storefront_before_header', 'storefront_add_topbar' );
    // END ENQUEUE PARENT ACTION
    
    ?>

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Hi there!

    Taking a quick look over the error message it would sound like you are using a child theme of storefront, correct? If that is so: AWESOME!!

    With that in mind would you mind posting the first 20 lines of your functions file?

    Not quite…

    endif;
    add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css' );
    // END ENQUEUE PARENT ACTION
    
    /**
    * Adds a top bar to Storefront, before the header.
    */
    function storefront_add_topbar() {
    ?>
    <div id="topbar">
    <div class="col-full">
    <p>Your text here</p>
    </div>
    </div>
    <?php
    }
    add_action( 'storefront_before_header', 'storefront_add_topbar' );

    No space underneath the last line of code…
    add_action( 'storefront_before_header', 'storefront_add_topbar' );
    …and No closing tag “?>

    Thread Starter Markb

    (@terasolar)

    Hi there,

    thanks again… that was my 2nd choice!

    I’ll give it a try and if there are any other questions I’ll back to you.

    Cheers,

    Mark

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘editing functions.php results in Parse error:’ is closed to new replies.