-
AuthorPosts
-
January 22, 2014 at 4:31 pm #7660
Howdy X,
I’ve reviewed all the support resources and documentation here regarding child themes and just want to be sure I understand everything before moving forward…
I find myself often hardcoding simple adjustments to the search results page and 404 page of most themes, since the theme author’s language (e.g. “Whoops! That page is missing…”) doesn’t always work for every site. Obviously a child theme would be the preferable way to handle these edits. So, for example, I’d just copy the exact file path of the 404.php file into my child theme, make my edits, and as long as that file is in the child theme my edits will remain despite updating the rest of X. I can just leave the original 404.php file in the main X install, correct? I don’t have to delete it? WordPress will just favor any file it finds in the child theme over a file of the same name/path in the original install… at least that’s my understanding.
If, though, I had made changes to a file via a child theme, but X rolled out some new killer feature that required updating that very file I was using in a child theme, I’d have to no choice but to make my edits again to the updated file, right? I got a little confused here because I see that the child theme comes with a blank functions.php file. So is the ideal workflow with child themes to upload the original file that INCLUDES your edits, or just a file of the same name and path but that contains ONLY the edits so that WordPress adjusts only the part of the file you changed in the child theme and gets the rest of the file from the main X install via a PHP argument?
Lastly, are updates made just to X? Or to the child themes as well? I noticed in the style.css file that the child themes are still at version 1.0, so my guess is that the child theme never really needs updating once it’s in place.
Thanks so much for clarifying!
PS: As a feature request, it’d be awesome to adjust the wording of 404 pages and search results pages (both with and without results) from within WordPress… I haven’t seen that in any other theme 😉
January 22, 2014 at 5:31 pm #7678Howdy Ryan,
Thanks for writing in and for providing such thorough information on this matter, you have no idea how much this helps us when going through these threads. 🙂
I know that you say you’ve read all of the documentation, but I just want to make sure that you’ve seen this article in the Knowledge Base about this exact subject. I only ask because we posted it very late last night in an effort to provide clarity on this very matter as it gets asked a lot. I think you’ll find that it goes into great detail on how to make these sorts of updates and how to manage them properly via a child theme.
If you’ve made template adjustments in a child theme and X rolls out a new big update that you want to upgrade too, everything in the theme will update automatically except for any templates you might have overwritten, but if you’re just using the child theme for basic updates like changing text here or there, you shouldn’t need to worry about this. The child themes that we provide setup all the necessary things in order for the theme to work properly, such as including the style.css file, pointing the child theme towards the parent directory, and importing the parent theme’s CSS. The blank functions.php file is just there as an added bonus to help people start out, but any updates you want to make to functions or templates will need to be added yourself (again, check out that link provided as it goes into all of this in depth).
The updates are made only to X. The child themes don’t really need any updating as they’re just there as a template to get you started. You can then take them and work with them the way you want. If we ever had to modify X’s main template files for example and the path structure to the CSS files got changed, then we’d have to change things like the @import statement to the child theme, but we would likely still leave it at v1.0.0 since these child themes aren’t that involved.
Also, thanks for the feature request! That’s certainly a neat idea and while we can’t make any promises, we’ll see what we can do going forward.
Your Friends in Texas,
ThemecoJanuary 22, 2014 at 6:06 pm #7686Themeco,
The speed with which your team responds and the quality of answer you provide (both here and on ThemeForest) are phenomenal. Thanks so much for providing this detailed response and helping me understand child themes, since I’ve never taken a stab at them before.
So just to be clear then… if I edit file.php in the child, for example, it will overwrite the entire file.php in the parent. Thus, file.php in the child would need the entire code from the file.php in the parent to stay functional, plus my new edits, correct?
That article’s last example you linked to does help – In calling the newly created global-alert.php in the wp-header.php child theme file, the wp-header.php also contains its original markup, which was part of my confusion. I wanted to be sure you couldn’t just call global-alert.php and leave it at that… you still have to include the rest of the original text since the child theme fully overwrites the parent edition of that file… it doesn’t combine it with the child’s.
Thanks again, you guys rock!
-Ryan
January 22, 2014 at 6:15 pm #7689Ryan,
Thanks for your kind words, it always means a lot to hear them around here. 🙂 You are correct, when you move a file over to overwrite it, you must first copy over all of the original contents of the file and then make your additions/modifications in the child theme. This only works for the Views though in the views folder (for modifying markup). As the article states, you must copy the same path in your child theme as well. I’d try a couple tests and work on setting everything up correctly. Once you’ve done it a couple times, you’ll be amazed at how easy it is.
Additionally, we take ratings very seriously around here. If you think we’ve earned it, we’d love to have your 5 star rating over at ThemeForest. You can do this by going here to submit your rating. If there’s anything else you need, just let us know.
Thanks!
January 22, 2014 at 6:26 pm #7691Themeco,
Thanks! Now I feel quite confident. I’ll run a few tests to get the hang of things.
And of course! I’ll be sure to rate X with 5 stars… I want to see it grow to be the best theme bar none, so any part I can do to aid in that endeavor is my pleasure.
See you around the forum!
-Ryan
January 22, 2014 at 6:47 pm #7696Thank you for the kind words! We really appreciate that.
October 11, 2015 at 2:08 am #620046Hello!
Thank you to Ryan and support for helping clarify this issue for me—excellent communication.
To bring this thread even further, how would one modify php files that aren’t in a specific view? From what I’ve seen in this thread, the answer is probably “hooks,” because we can only do the file path thing for php files in views. Hooking filters and actions seems to be what is needed… So, how would we modify /x/framework/functions/global/featured.php from the child theme?
To be specific with what I’m trying to do here, I’m wanting to pull the image caption from each photo in a the featured gallery to use as a label. Here’s a (maybe) helpful link regarding the gallery caption: https://wordpress.org/ideas/topic/functions-to-get-an-attachments-caption-title-alt-description also, https://wordpress.org/support/topic/get-attachment-description-for-gallery
I’ve read this https://community.theme.co/kb/customization/actions-and-filters-in-x/ and the above-linked one about views.
Thank you for any and all help in understanding X’s functionality… and maybe even help with my specific challenge.
October 11, 2015 at 4:30 am #620151Hey there,
What you need requires that you know how to use WordPress APIs or WordPress development in general. Regretfully, we could not provide instructions for that as it is such a wide scope. There are many WordPress development tutorials online and once you gain knowledge of that, you will be confident in modifying X as it is composed of WordPress APIs and standard WordPress development techniques.
Thank you for understanding.
February 5, 2016 at 9:06 am #781675I’m also looking for an answer to this question. Specifically, I’m trying to remove that pesky “Permalink to:” from my hover labels. I’m afraid that every time I update the theme I will have to make that fix, if I remember where it was. Modifying a copy in x-child doesn’t affect the result.
/x-child/framework/functions/global/featured.php
Doesn’t overwrite
/x/framework/functions/global/featured.php
February 5, 2016 at 6:02 pm #782406Hi There,
You can only modified a template under /framework/views/. Functions should be placed on the child theme’s functions.php file.
e.g.
// // Output featured image in an <a> tag on index pages and a <div> for single // posts and pages. // if ( ! function_exists( 'x_featured_image' ) ) : function x_featured_image( $cropped = '' ) { $stack = x_get_stack(); $fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false; if ( has_post_thumbnail() ) { if ( $cropped == 'cropped' ) { if ( $fullwidth ) { $thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL ); } else { $thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL ); } } else { if ( $fullwidth ) { $thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL ); } else { $thumb = get_the_post_thumbnail( NULL, 'entry', NULL ); } } switch ( is_singular() ) { case true: printf( '<div class="entry-thumb">%s</div>', $thumb ); break; case false: printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>', esc_url( get_permalink() ), esc_attr( sprintf( __( 'Permalink to: "lorem ipsum dolor"', '__x__' ), the_title_attribute( 'echo=0' ) ) ), $thumb ); break; } } } endif;
Hope it helps, Cheers!
-
AuthorPosts