• I have managed to create a child theme, albiet very basic (it just has a stylesheet). But say I’ve made changes to the main theme (Twenty Ten) in loop.php and functions.php, and a couple other files – how would I include these in the child theme folder?

    I found this on the WP Codex page….

    Other files

    In addition to files such style.css, functions.php, index.php, and home.php, a child theme can use any type of file full-fledged themes use, as long as that file is properly linked. For example, it can use icons and images that are linked from its stylesheet, JavaScript files linked from the top or bottom of pages, or extra PHP files called from templates or from functions.php.

    So how do I “properly link” my other files?

    Thanks.

Viewing 15 replies - 1 through 15 (of 31 total)
  • All you need to do is place your new template and function.php files in the child theme.

    Thread Starter dcloud

    (@dcloud)

    But I don’t have a template. Just created a folder and put a style.css file in it. If I try using the other files from my main theme it gives me errors.

    Like I said in my last post – on the Codex web site they said the files should be “properly linked”. I want to know how to link them.

    If I try using the other files from my main theme

    “Using them” in what way?

    Thread Starter dcloud

    (@dcloud)

    I have some things I’ve made changes to in other files – like funtions.php, index.php, etc. You can’t just stick the whole file in there (in the folder with the child theme) without properly linking it.

    There’s a way to do this and that’s what I need to know.

    dcloud, it depends on what you want to do.

    If you want to use some JavaScript files, for example, you enqueue them from your functions.php using the WordPress Script API.

    If you want to use some extra PHP files for which WP does not offer a standard way, you use the appropriate PHP constructs: include, require, include_once, require_once.

    If you want to use images for your styling, you can link them from your style.css.

    You can go a long way by using just your main CSS file and images linked from it. For the other parts, you can start by reading on:

    First, WordPress templates.

    Second, the WordPress Plugin API. (Which is not just for plugins, but for every piece of code that wants to extend or modify WordPress.)

    You can’t just stick the whole file in there

    Oh yes – you do. You don’t have to “link” to anything. In the case of the child’s functions.pp file, it should only contain the modified functions – without the if( function_exists() ...endif conditional.

    Thread Starter dcloud

    (@dcloud)

    Ok, for example……

    I have made a modification to the funtions.php where I inserted my logo over where the text name usually is. Like so…

    <h1 id="site-title">
    <span>
    <a href="<?php bloginfo ('home');?>" rel="home" title="<?php bloginfo('name');?>"/>
    <img src="<?php echo bloginfo ('template_directory');?>/images/ddlogo.jpg" alt="<?php bloginfo ('name');?>" />
    </a>
    </span>
    </h1><!--end of h1 site-title-->

    Now I’m not sure how to make this work as a funtions.php file in the child theme. I tried just putting it between beginning and ending PHP tags, but I get the following error….

    Parse error: syntax error, unexpected ‘<‘ in /home/dcloud/public_html/wp-content/themes/twentyeleven/functions.php on line 3

    So I’m not sure how to make these files work. Obviously I need to add some kind of proper link, as the Codex page says. I just don’t know how to do it. I’m not a coder.

    Sorry. Did not see your last post.

    For index.php: An index.php in a child theme’s folder overrides automatically, just by existing, the parent’s index.php. The same goes for ALL template files. So, you can make something completely different from what the the parent offers, or you can take the parent’s template file and just modify a bit or two in it.

    For functions.php: You can have a functions.php in your child theme containing just the extra bits you want to add. WordPress loads both functions.php files. First the child’s, then the parent’s.

    In your example, you need to place a copy of the header.php template file – complete with your modifications – in the child theme.

    Thread Starter dcloud

    (@dcloud)

    In your example, you need to place a copy of the header.php template file – complete with your modifications – in the child theme.

    Yes, but how? You mean place the whole thing in there, just as it is? Sorry, I don’t know anything about this stuff.

    Copy the parent header.php file into a plain text editor on your machine. Add your modifications and then save the file. Upload it to the child theme using FTP (or whatever file management application your host provides).

    Thread Starter dcloud

    (@dcloud)

    But why would I open the file and make any changes? The file already has my changes in it. I want to keep all the little changes I’ve made in the different files (within the child theme folder) so they don’t keep disappearing every time there’s a WP update.

    So again, my question is, how do I place these files (the ones I’ve made changes in) into the child theme folder without getting the parse and syntax errors?

    And where is this amended file?

    Thread Starter dcloud

    (@dcloud)

    There is no amended file. I’ll say it again….I have made changes already to files in the Twenty Ten theme (folder). I want to keep these changes so they don’t disappear when I update WP or the theme. So what I want to know is how to keep these changes – how do I place these files in the child folder so I can keep the changes?

    I want to keep these changes so they don’t disappear when I update WP or the theme.

    Then you have to create a child theme. You shouldn’t have amended Twenty Ten in the first place.

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Adding other files to a child theme?’ is closed to new replies.