Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #113482

    Peter C
    Participant

    I need to add some code to the header.php, but I’m a little unclear how this works with child themes (stacks).

    Can I do this from within the appearance editor in wordpress?

    Also, when I update X, will this code I add be overwritten?

    Thanks

    Peter

    #113526

    Nabeel A
    Moderator

    Hi Peter,

    Always use a child theme if you need to edit core files, otherwise all the customizations will be lost on update.

    To edit header.php file. First setup the child theme, you can refer to this article http://theme.co/x/member/kb/how-to-setup-child-themes/ then copy the wp-header.php file from X\framework\views\your-stack-name\wp-header.php and paste it inside the child theme directory here x-child-your-stack-name\framework\views\your-stack-name

    Then add your code inside. You’ll need FTP to edit the child theme files.

    Let us know if this helps!

    #113529

    Peter C
    Participant

    When X updates… Will I have to update the file I created in the child theme?

    #113635

    Christopher
    Moderator

    Hi there,

    When you make changes to Child theme the changes will not overwrite and no need to update them.

    Hope it helps.

    #113663

    Peter C
    Participant

    When you refer to x-child-your-stack-name\framework\views\your-stack-name

    I’m looking at my child theme folder, but there’s no framework directory…

    Here’s what’s inside my child theme folder:

    functions.php
    screenshot.png
    style.css

    Am I looking in the wrong place???

    #113691

    Peter C
    Participant

    I’m trying to add some CSS links into the head section… is wp-header.php the correct place for this???

    #113745

    Kosher K
    Member

    Hi Peter,

    Please download a child theme in here -> http://theme.co/x/member/child-themes/

    each child theme have this kind of directory x-child-[your-stack]/framework/views/[your-stack]

    e.g. /x-child-ethos/framework/views/ethos

    you can add additional meta in here -> x-child-[your-stack]/framework/views/global/_header.php.

    but you don’t necessarily need to add it in there, you can simply use your child theme functions.php and hook your css file in wp_head.

    like this

    add_action('wp_head','my_addition_css');
    function my_addition_css() {
     echo '<link rel="stylesheet" href="www.your-site.com/your-css-file.css" type="text/css" media="all" />';
    }

    Hope that helps.

    #114577

    Peter C
    Participant

    My child theme does NOT have this directory: x-child-[your-stack]/framework/views/[your-stack]

    It only has the files I mentioned above.

    I ended up adding the directories, and that worked.

    #114609

    Cousett
    Member

    We are so glad you figured it out and all is working well. Have a wonderful day.

    #320511

    justcallmelody
    Participant

    Hello,
    After updating a plugin and entering a valid API code for auto-updates I saw the statement across the top of the page “Your theme needs to be fixed for plugins to work. To fix your theme use the Theme Editor to insert <?php wp_head(); ?> just before the </head>…

    I used the link to the Theme Editor and saw that I was in the Child’s Theme, I was not sure where to place the code above as I could not find a header.php file. SO, I entered the code into the function area, clicked Update, and saw that the statement did not go away. I then removed the code from the function area and refreshed, did not hit Update again. Now I cannot see anything on the Theme Editor page, or anywhere else. I used a different browser and typed in my URL justcallmelody.com – nothing shows up. It is a complete blank page.

    Can you help me?

    #320777

    Rue Nel
    Moderator

    Hey @justcallmelody,

    Thanks for updating this thread!

    You are experiencing a white screen which usually means there is a fatal PHP error. Can you please enable WP_DEBUG mode? You can do this by opening wp-config.php and adding
    define( 'WP_DEBUG' , true ); just above /* That's all, stop editing! Happy blogging. */ For example:

    define('WP_DEBUG', true);
    
    /* That's all, stop editing! Happy blogging. */

    When you revisit the page with the white screen, you should have some error output describing the issue in more detail.

    Please let us know how it goes.

    #393752

    djh-cs
    Participant

    Hi,

    When altering the header.php file in the child theme you say it won’t be touched when X updates (which I fully understand) but what if a future update relies on any header.php changes? Will it inherit those changes?

    #393787

    Paul R
    Moderator

    Hi,

    No, it will not inherit the changes. You will need to copy the updated code again and apply your change to it.

    Though this seldom happens and if it happens, the details of the change will be in the changelog with instruction on how to update your theme.

    https://theme.co/changelog/

    #854512

    Andy
    Participant

    Hello,

    I am trying to do the same thing, noticing in ftp that my child theme is at

    public_html/<my domain>/wp-content/themes/x-child/framework/views/integrity

    rather than

    public_html/roadtripsharing.com/wp-content/themes/x-child-integrity/framework/views/integrity

    In other words it goes themes/x-child instead of themes/x-child-your-stack-name.

    I noticed the download link above “Hi Peter,

    Please download a child theme in here -> http://theme.co/x/member/child-themes/” is broken so maybe I’m fine, if this thread has to do with an older version of child themes?

    Just want to make sure I don’t need to update my file structure somehow.

    Thanks.

    #854613

    Christian
    Moderator

    Hey Andy,

    The only difference between the old (x-child-your-stack-name) and the new child themes (x-child) are

    1. @import line is no longer present in the new child because
    2. it is replaced by the new function

    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );

    What it does is get the styles of a Stack dynamically.

    With that said, to transition to the new child theme, you would need to add that function in your functions.php and remove the whole @import line in your style.css.

    Thanks