• Resolved AardvarkGirl

    (@aardvarkgirl)


    I have a parent theme and I’ve created a child theme for it with a style sheet and an images folder. http://barnyarddesigner.com/

    Two issues.

    1. Images. I’ve edited the images (color scheme) and saved them as the same exact file name but put them into the child theme’s image folder. Am I correct in assuming the fix for the images that are being used in the parents style.css is to find every instance of a style that is calling an image and then put that style into the child style sheet?

    For example the parent style.css has this

    .bg {background: url(images/bg.jpg) center top repeat;}

    so I need to just put this same exact thing into the child style sheet? (which I did, and it is pulling the image from the child’s folder VS the parents).

    Just double checking that the fix is indeed doing a search in the parent style.css for anything /image and then just copying/pasting that style exactly as is into the child’s theme (again, because the images were edited/changed for color scheme).

    2. Styles being defined from another style sheet withing in the parent’s css folder.

    For example, the scroll arrows for the homepage’s slider – when you scale the browser down to a tablet size a different style sheet from the parent css folder is being used.

    Of course there are some other styles that are non-image related that are coming from the various display size-specific style sheets.

    What is the most efficient way to deal with this?

    At first I tried copying the entire css folder (with all the .css files) into the child theme and it didn’t do any good.

    Then I realized the header.php in the parent theme is calling multiple style sheets (8 total, not couting those for IE) using this:

    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/css/normalize.css" />
    	<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
    	<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/css/skeleton.css" />
    	<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/css/touchTouch.css" />
    	<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/css/768.css" />

    In the end I was about ready to throw my hands up and just save the header.php file into the child theme and change the <?php bloginfo( ‘template_url’ ); ?> to <?php bloginfo( ‘stylesheet_url’ ); ?> based on something I read… but then I thought “Well does that defeat the purpose of using a child theme? I mean the header.php has some pretty significant info in it that the developer may change over time, eh?”.

    Thanks so much for your replies. 🙂

Viewing 15 replies - 1 through 15 (of 17 total)
  • 1.
    Yes. When child theme is in used, relative path to images folder like that is refering to images folder in child theme.

    2.
    Depends on how parent theme enqueue all those stylesheets.

    In most cases, using just the @import to pull the whole parent style in the child style will take care of everything.

    In some cases, parent theme enqueues all those stylesheets using either a. or b.

    a. get_template_directory_uri
    b. get_stylesheet_directory_uri()

    If a. then childtheme will get only that same set of stylesheets unless childtheme remove them (via action hook) and replace with its own.

    If b. then childtheme will be able to put in its own set of stylesheets overriding the parents just like the images in CSS.

    Thread Starter AardvarkGirl

    (@aardvarkgirl)

    I’m not hugely experienced in this so I have to ask, then what is the ‘correct’ way to resolve this?

    I created a child theme and started with the style sheet and the images folder (so I could change the color scheme).

    All other files are in the parent theme. The header is calling all these style sheets using exactly this:

    <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/css/normalize.css" />
    	<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
    	<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/css/skeleton.css" />
    	<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/css/touchTouch.css" />
    	<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/css/768.css" />

    Does that mean I need to save a copy of header.php to my child theme folder?

    Thread Starter AardvarkGirl

    (@aardvarkgirl)

    Ok, simply putting a copy of header.php in the child theme folder is not changing the directory of the images being used when the site gets scaled down to ‘hand held’ size. :-\

    The theme you are using is not hosted at WP.org. So you should be able to get support directly from the site where you get this theme from.

    AND more importantly, its name “Theme Name: theme1847” doesn’t sound right at all. It’s better not to download theme from untrusted site, because sometimes it comes with malicious code.

    Anyway, to answer your question. With that 5 lines of code in parent’s header.php, the 2nd one means that the active theme’s stylesheet will get loaded ( in that order ).

    So with a child theme activated, you need to have a copy over of the whole parent’s style.css in child theme folder AND the images folder with the same set of images.

    If you need to override something from the stylesheet loaded below(after) the 2nd line, you need to use CSS selector with higher specificity, or override the header.php to load your own version of the entire file.

    Theme Name: theme1847″ doesn’t sound right at all. It’s better not to download theme from untrusted site

    Definitely.

    That vendor also does not comply with the GPL licensing requirements of WP either – we really cannot support non-GPL themes here at all.

    Thread Starter AardvarkGirl

    (@aardvarkgirl)

    Paul – I got the theme from a ‘trusted source’ :-\

    Are you saying if you are creating a child theme (from whatever parent theme) or if you are hacking a theme, you can’t ask general questions that are in regards to using WordPress functions here on this forum?

    So with a child theme activated, you need to have a copy over of the whole parent’s style.css in child theme folder AND the images folder with the same set of images.

    Yes, I created a child directory, uploaded a copy of the style.css and the images folder (after editing the color of the images) to the child directory.

    THEN I copied header.php into the child theme’s folder and have been trying to figure out WHAT FUNCTION to use to use to get it to call all the style sheets from the child theme folder.

    http://codex.wordpress.org/Function_Reference/bloginfo

    ‘template_url’ / ‘template_directory’ – URL of the active theme’s directory (‘template_directory’ was a local path before 2.6; see get_theme_root() and get_template() for hackish alternatives.) Within child themes, both get_bloginfo(‘template_url’) and get_template() will return the parent theme directory. Consider echoing get_template_directory_uri() instead (for the parent template directory) or get_stylesheet_directory_uri() (for the child template directory).

    That vendor also does not comply with the GPL licensing requirements of WP either – we really cannot support non-GPL themes here at all.

    Thread Starter AardvarkGirl

    (@aardvarkgirl)

    Oooook then. I’ll start another thread about best practices dealing with multiple parent style sheets in child themes. :-\

    Are you aware that some themes simply won’t work with child themes?

    Thread Starter AardvarkGirl

    (@aardvarkgirl)

    WPyogi – nooooo, no sir, I did not. And that is why I come here to ask questions. So I can learn.

    All I know is most posts I’ve found in regards to modifying the look of a theme include someone posting “DON’T EDIT THE THEME, MAKE A CHILD THEME!!!”.

    I didn’t come here to ask for ‘support’ as in ‘someone please fix this for me’. I came here to learn something. I pulled apart this theme because I was curious about how it was doing the resizing for handhelds compared to another responsive theme I’ve got. When I set up a child theme that’s when I noticed how all the style sheets were being called in.

    http://wordpress.org/support/topic/is-it-possible-to-edit-html-in-a-child-theme?replies=8

    (Not a sir, BTW 🙂 ) – I totally admire and support your willingness to jump in and learn. But the issue about GPL is important – WordPress is what it is in large part because of it – so when you use a theme that’s not GPL, it’s contrary to the spirit and policies of WP and these forums. I’d really encourage you to rethink using any theme that’s not GPL.

    And yes, not all themes will work with child themes – which IMHO, is another good reason to not use that theme :).

    Thread Starter AardvarkGirl

    (@aardvarkgirl)

    Ok, perhaps TemplateMonster should out right state their themes are not GPL… cuz that’s where we got it from. :-\

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    perhaps TemplateMonster should out right state their themes are not GPL

    Some theme vendors even boldly state their themes are released under GPL but clearly violate key GPL specifications like preventing users from modifying particular sections of the theme (usually because there’s some nasty spam in there).

    The stylesheet shows a different vendor – whose licensing info is clearly not GPL. It’s probably always good to double-check on the licensing info in the theme style.css file – as that’s what people here will look at.

    This might be helpful too – as these vendors ARE GPL (if you find otherwise, please let us know 🙂 ):

    Commercially Supported GPL Themes

    Thread Starter AardvarkGirl

    (@aardvarkgirl)

    ???

    /*–
    Theme Name: theme1847
    Theme URI: http://template-help.com/
    Description: A theme for WordPress 3.2+ from Template-Help.com Collection
    Author: Template_Help.com
    Author URL: http://www.Template-Help.com/
    –*/

    http://www.templatemonster.com/help/template-help-com/

    And here is the license that came with it: http://barnyarddesigner.com/wp-content/themes/theme1847/license.txt

    And let me say again, I’m not coming here asking the WordPress.org forum community members or it’s moderators to FIX something, I was comparing this theme’s functionality to another and had general questions about the use of http://codex.wordpress.org/Function_Reference/get_template_directory_uri or this http://codex.wordpress.org/Function_Reference/bloginfo and how multiple style sheets on a parent get handled in a child. :-\

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Child theme, obeying multiple style sheets in parent theme (specifically images)’ is closed to new replies.