WordPress.org

Forums

Steps to creating a child theme (23 posts)

  1. davidloc
    Member
    Posted 1 year ago #

    I am using a theme that has frequent updates and wish to use a child theme to conserve all of the settings (menus, backgrounds, RSS, Facebook links , Contact info , etc. I have it set up with a child theme directory as per the codex with style.css and some of the customizations do get saved. My problem is that menu creations , links , custom pages don't get saved after an update. For instance what files would I put in the child theme to save the menus ? admin.php? What would the file structure be like. Does it use the same process as style.css with the theme info then the include for the parent style.css then the customizations after? The codex is very bare bones when it comes to this. Also how would I redirect the image folder from the parent theme image directory to the images directory in the child theme ? I am having difficultly finding the correct url to use in header.php that I also have a copy of in the child theme.

    Thank you for any help with this

    David

  2. stephencottontail
    Member
    Posted 1 year ago #

    Custom menus are saved by WordPress. Since a child theme is considered a new theme by WordPress' standards, though, you'll have to remake any custom menus from your Dashboard and assign them to the appropriate locations, just like you did when you were using the parent theme. You would also have to do the same thing with any widget areas, as well.

    Re: your image problem. get_template_directory_uri() should return the parent theme's directory, so in your child theme you could use, for example: <img src="<?php echo esc_url( get_template_directory_uri() . '/path/to/image.jpg' ); ?>" and it would return the appropriate image from the parent theme's image directory.

  3. davidloc
    Member
    Posted 1 year ago #

    There is no way to have the menu customizations stored in the child theme instead of the parent theme ? Also I want to use the images directory that I created in the CHILD theme not the images directory in the parent theme but get_template_directory_url always returns the parent images directory. How would I get it to return the child images directory instead ? I have full ftp and shell access to the server the website is on.

    Thank you for your quick reply Stephan :)

  4. stephencottontail
    Member
    Posted 1 year ago #

    Re: your menu customizations. Are you referring to the content of your menus (links, pages, categories, etc.) or the styling of your menus (colors, fonts, etc.)?

    Re: your image directory. I misunderstood your question at first, my apologies. To return the child theme's assets, you would use get_stylesheet_directory_uri() instead.

  5. davidloc
    Member
    Posted 1 year ago #

    For instance with the menu creation , I would like that information stored with the child theme, storing the attributes of the menu items would be a huge plus as it will be quite detailed once it is complete.

    I have WordPress design for dummies , Professional WordPress design and development , WordPress pushing the limits , PHP and MySql for dynamic websites and CSS3 the missing manual to help figure out how to do this. Along with the Codex , the same information is given with just a partial list of files that can be stored in the child and "make the same directory structure but it never goes beyond that with any details.

  6. stephencottontail
    Member
    Posted 1 year ago #

    Sorry, but I'm still not following you. Are you referring to the content of your menus (links, pages, categories, etc.) or the styling of your menus (colors, fonts, etc.)?

  7. davidloc
    Member
    Posted 1 year ago #

    The menu structure and naming and where each menu item is linked to is the most important

  8. stephencottontail
    Member
    Posted 1 year ago #

    That should have been saved for you. Go to your Dashboard, select Appearance > Menus, and check the "Select a menu to edit" dropdown. Your menu should be in that list. Then go to the "Manage Locations" tab and assign that menu to the appropriate location using the dropdown menu.

  9. davidloc
    Member
    Posted 1 year ago #

    I just noticed that the menu structure is not saved with the themes at all and feel dumb , lol. Is there a tutorial on how to put the different files correctly into a child theme ? eg , header.php , footer.pho , etc ?

  10. stephencottontail
    Member
    Posted 1 year ago #

    Generally speaking, the only files you need to include in a child theme are the files that should be different from the parent theme. If you like the general design of your theme but you'd like to use different colors or fonts, all you need to do is include a new stylesheet. Your question is quite broad, though, and if you could narrow it down to what specific changes you'd like to make, it would be a lot easier to help. Also, I suggest making separate threads for each question. It makes it easier to help. What theme are you using?

  11. davidloc
    Member
    Posted 1 year ago #

    The theme is New-Commerce by F5 THemes. (http://f5themes.com/) I would like to retain the header images and background ground images as well as their settings. The site I am working on is can.wandasweb.com there is a corresponding usa.wandasweb.com these are place holder URLs so that temporary URLs don't have to be used which seems to break many plugins once the temporary URL is changed to the permanently published one. I have not put in any shopping data so the sliders are not showing yet.

    Thank you very much Stephen , this is very helpful and appreciated

  12. stephencottontail
    Member
    Posted 1 year ago #

    It doesn't look like you need a child theme for anything, to be honest. It looks like can.wandasweb.com is using a plugin called Background Manager[*] to set the background image. You could use the same plugin and the same image on usa.wandasweb.com to get the same effect.

    [*] It looks like the plugin is no longer supported or maintained. It will probably still work for the immediate future, but you may wish to search for an alternative plugin.

  13. davidloc
    Member
    Posted 1 year ago #

    The two flags and their links , the front page header image is also custom. The menu as well is modified to remove the border from the top and bottom. How would I retain these settings ?

  14. stephencottontail
    Member
    Posted 1 year ago #

    As I do not have access to your chosen theme, I cannot say how to add the header image from usa.wandasweb.com. I would ask your theme vendor for assistance on that front. But I can say that your two sites are exactly the same, except that can.wandasweb.com has a background image that usa.wandasweb.com does not. If you install the Background Manager plugin I mentioned in my previous post and use the same background image and the same plugin settings, your two sites will look the same.

  15. davidloc
    Member
    Posted 1 year ago #

    It is losing the settings when the theme is updated that I am concerned about. I am working on getting can.wandasweb.com set up and then once complete will be redirecting http://www.wickedwandas.ca to this site so I want the updates as painless as possible before this.

  16. stephencottontail
    Member
    Posted 1 year ago #

    Your background image will be set by the plugin, so no worries there. Your menu is preserved by WordPress, so no worries there. From what I've seen on your two sites, it doesn't look like anything would be removed by a theme upgrade.

  17. davidloc
    Member
    Posted 1 year ago #

    Actually the flags are inserted in style.css and the menu shadow is removed in the menu_wrapper property in header.php

    That is what I have so far

  18. stephencottontail
    Member
    Posted 1 year ago #

    Since I don't have access to your theme, it's a bit difficult to tell exactly how you changed those things. What file did you edit to add the flags to your header? I don't see any reference to the flags in your stylesheet. What file did you edit to remove the menu shadow?

  19. davidloc
    Member
    Posted 1 year ago #

    <div class="span1" style="float:right;">
         <a href="http://www.wickedwandas.ca"><img src="<?php echo get_template_directory_uri(); ?>/images/Canada-icon.png" /></a>
         <a href="http://www.wickedwandas.com"><img src="<?php echo get_template_directory_uri(); ?>/images/usa-icon.png" /></a>
        </div>

    will be added to header.php

    #wrapperHeader .container {
    margin-top: 0px;
    }
    
    #wrapperHeader {
     margin-bottom:0px;
    }

    will be added to style.css

    this is what gets wiped out so far if I don't put it in the child theme

  20. stephencottontail
    Member
    Posted 1 year ago #

    Well, you pretty much answered your own question there. Make a copy of your parent theme'sheader.php in your child theme's directory and add your code to it. Add your CSS code to your child theme's style.css and you should be good to go.

  21. davidloc
    Member
    Posted 1 year ago #

    That was part of my original question. How does the header.php get formatted when it is a copy in the child theme meant to override a setting on the parent header.php . ie information needed in the file , include line , etc . Only style.css is covered well in any child theme usage guide I have ever seen

  22. davidloc
    Member
    Posted 1 year ago #

    I currently have those lines in the parent header.php

  23. stephencottontail
    Member
    Posted 1 year ago #

    First, check out WordPress' template hierarchy. When you're using a child theme, WordPress first looks for the appropriate template file in the child theme's directory. If it doesn't find the appropriate file, it will then look in the parent theme's directory. So in your particular case, once you add header.php to your child theme, WordPress will always use your child theme's version and not the parent theme's version.

Topic Closed

This topic has been closed to new replies.

About this Topic