-
AuthorPosts
-
September 26, 2014 at 4:42 pm #113482
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
September 26, 2014 at 6:17 pm #113526Hi 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!
September 26, 2014 at 6:25 pm #113529When X updates… Will I have to update the file I created in the child theme?
September 27, 2014 at 3:37 am #113635Hi there,
When you make changes to Child theme the changes will not overwrite and no need to update them.
Hope it helps.
September 27, 2014 at 5:45 am #113663When 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.cssAm I looking in the wrong place???
September 27, 2014 at 7:29 am #113691I’m trying to add some CSS links into the head section… is wp-header.php the correct place for this???
September 27, 2014 at 10:16 am #113745Hi 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.
September 29, 2014 at 5:33 am #114577My 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.
September 29, 2014 at 6:22 am #114609We are so glad you figured it out and all is working well. Have a wonderful day.
July 3, 2015 at 6:12 pm #320511Hello,
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?
July 4, 2015 at 2:54 am #320777Hey @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.
September 17, 2015 at 4:20 am #393752Hi,
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?
September 17, 2015 at 5:23 am #393787Hi,
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.
March 27, 2016 at 6:30 pm #854512Hello,
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.
March 27, 2016 at 8:30 pm #854613Hey 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
-
AuthorPosts