• Resolved Hendrik57

    (@hendrik57)


    I made a child theme as usual. To start with the style.css. It has no additional styling yet.
    I activate it, ok. (no errors, wp debug true)
    But then it seems that references to content in the parent thema are replaced by references to non existing paths in the subtheme. These refs should stay with the parent unless overruled by the child theme.

    But there is more. The primary menu and page is not build correctly. Text is shown like this:

    Primair menu

    Menu
    Zoeken naar: Zoeken
    Home
    Wie ben ik
    Werkwijze
    Portfolio
    Prijs
    Contact

    And then some content is shown, but not as i’d expect.
    What is happening? (I cleared all caches and all wordpress is up-to-date)

    The strange thing is that this is not happening when I activate the example child.

    • This topic was modified 8 years, 2 months ago by Hendrik57.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Theme Author Tomas Mackevicius

    (@tomasm)

    Hi!

    Please use the provided child theme example. It is in the theme’s inc/examples folder.

    Unfortunately because of my free time availability I can only support child theme example.

    But if you will find the cause, please let me know.

    Thread Starter Hendrik57

    (@hendrik57)

    Ok. I try to find things.

    Wrong path to custom header pics when using a child theme

    In custom-header.php there is:
    'default-image' => '%2$s/images/headers/Tiny-Framework-header-01.jpg',
    This points to the thema path. Acually to the child now. But there are no images there.
    So it should be (on line 23)
    'default-image' => '%s/images/headers/Tiny-Framework-header-01.jpg',
    and when someone wants to use an other set then the defaults, they should write a function in the theme functions.php.
    In the same custom-header.php file the same corrections should be done to the lines 49-65:

    	register_default_headers( array(
    		'First'  => array(
    			'url'           => '%2$s/images/headers/Tiny-Framework-header-01.jpg',
    			'thumbnail_url' => '%2$s/images/headers/Tiny-Framework-header-01-thumbnail.jpg',
    			'description'   => esc_html_x( 'First', 'header image description', 'tiny-framework' )
    		),
    		'Second' => array(
    			'url'           => '%2$s/images/headers/Tiny-Framework-header-02.jpg',
    			'thumbnail_url' => '%2$s/images/headers/Tiny-Framework-header-02-thumbnail.jpg',
    			'description'   => esc_html_x( 'Second', 'header image description', 'tiny-framework' )
    		),
    		'Third'  => array(
    			'url'           => '%2$s/images/headers/Tiny-Framework-header-03.jpg',
    			'thumbnail_url' => '%2$s/images/headers/Tiny-Framework-header-03-thumbnail.jpg',
    			'description'   => esc_html_x( 'Third', 'header image description', 'tiny-framework' )
    		),
    	) );
    

    should be replaced with:

    	register_default_headers( array(
    		'First'  => array(
    			'url'           => '%s/images/headers/Tiny-Framework-header-01.jpg',
    			'thumbnail_url' => '%s/images/headers/Tiny-Framework-header-01-thumbnail.jpg',
    			'description'   => esc_html_x( 'First', 'header image description', 'tiny-framework' )
    		),
    		'Second' => array(
    			'url'           => '%s/images/headers/Tiny-Framework-header-02.jpg',
    			'thumbnail_url' => '%s/images/headers/Tiny-Framework-header-02-thumbnail.jpg',
    			'description'   => esc_html_x( 'Second', 'header image description', 'tiny-framework' )
    		),
    		'Third'  => array(
    			'url'           => '%s/images/headers/Tiny-Framework-header-03.jpg',
    			'thumbnail_url' => '%s/images/headers/Tiny-Framework-header-03-thumbnail.jpg',
    			'description'   => esc_html_x( 'Third', 'header image description', 'tiny-framework' )
    		),
    	) );
    

    Next I will try to find out why the menu is a ‘list of text’. (this happens on all servers I tried with php7)

    Thread Starter Hendrik57

    (@hendrik57)

    The lay-out trouble seem to be caused by the fact that the childtheme can not find the parent styles and so on.
    Therefore a functions.php is needed, next to the style.css.
    The functions.php example in the \themes\tiny-framework\inc\examples folder did the thing. As far as I can overlook only the essential functions are activated. There are no additional functions or functions that replace the parent theme.

    So the minimum child theme exists of style.css (only the header) and functions.php (like the example)

    The above correction of custom-header.php is needed, or one should make a duplicate of the images folder in the child theme. In that case one could replace thesed with other images.

    Btw. I like the comments and explanation in the theme files!

    Theme Author Tomas Mackevicius

    (@tomasm)

    Thank you for the investigation!

    As I noted in the custom-header.php comments:

    %s is a placeholder for the theme template directory URI.
    %2$s is a placeholder for the (child) theme stylesheet directory URI.
    I’m using %2$s to make it easy for the user to replace default header images in a child theme.

    So the main intent is for the users who do not really want to mess with creating their own child theme, but I will definitely add your findings to the online manual so users would know that they have to copy over the header files.

    I tested a child theme with custom-header.php and %s – when using a child theme the Customizer shows the parent theme header images, so not useful for real world scenario where people what to see header selection for the images they have included with the child theme.

    Thank you again!

    Thread Starter Hendrik57

    (@hendrik57)

    I can agree with your explanation.
    However, when I select my own image in the customizer, this image is not shown when I switch to the child. I have to select this image again.
    The approach is usefull when someone wants other default images for some purpose.

    Child is working now, with no changes to the original (parent). Thanks.

    Thread Starter Hendrik57

    (@hendrik57)

    On this line in functions.php seems to be an extra ‘?>’ at the end of this line:

    	 * Standard Post Thumbnail can be inserted with <?php the_post_thumbnail(); 
    
    Theme Author Tomas Mackevicius

    (@tomasm)

    You see, this is not to be uncommented, it is just info. I appended to the comment:

    Standard Post Thumbnail can be inserted in the theme files with..

    Thread Starter Hendrik57

    (@hendrik57)

    In the above line, I removed the ending ‘?>’. Comment will stay comment. My editor sigaled a mismatch with te starting php tags.

    Theme Author Tomas Mackevicius

    (@tomasm)

    BTW you may want to read:

    https://justintadlock.com/archives/2014/11/03/loading-parent-styles-for-child-themes

    Justin here says:

    The major problem with this method [the one being used in Tiny Framework] is that we’re putting users (often first-time users) into the functions.php file, which can be a dangerous place. One mistake here and you’ll definitely bring your site down.

    The thing is that I want intentionally drive users to look at functions.php and experience those dangers, as making mistakes is the way to learn ??

    Another older thread: https://github.com/Automattic/_s/pull/638

    Anyway, I always look what happens in the development of default themes and if some or the other method becomes more prevalent, I would consider it.

    As we can see, this discussions is also present in Twenty Seventeen:

    https://github.com/WordPress/twentyseventeen/issues/67

    So we will see… ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Simple child theme is not working’ is closed to new replies.