Skip Navigation

[Resolved] Child theme header.php not being used on Toolset pages.

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 6 replies, has 2 voices.

Last updated by Nigel 6 years ago.

Assigned support staff: Nigel.

Author
Posts
#431981

I am using Toolset with a child theme for Twenty Sixteen with the Toolset Twenty Sixteen integration.

None of my Pages which use Toolset Layouts respect the header.php file in the child theme...nor do they seem to pull the header from the parent theme.

I have a line of code in both parent and child header.php files that is not showing on the pages governed by Toolset Layouts

Pages which do not use a toolset layout (my events) however, do respect the header file.

I can use a function to add my line of code to wp_head. However, this places the code in the wrong spot...i need it to be before all style sheets. ( <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />)

How do I get this below the <head> tag on my Toolset Layout pages?

#431995

So apparently, if I put my code in /wp-content/plugins/layouts-twentysixteeen/application/theme/view/header.php I can get it to show on my Toolset pages.

Now, the question is: can that file be moved into my child theme because I don't want the edit overwritten when the plugin is updated?

#432427

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

The WordPress template hierarchy is used to govern which PHP template files are used to build the page (https://developer.wordpress.org/themes/basics/template-hierarchy/), and normally if you want to customise how your pages are constructed that involves editing your theme's template files.

Layouts allows you to do the same without editing the PHP templates, it bypasses the normal WordPress templating system and allows you to build the entire page layout, including header and footer, using drag 'n drop.

So any page that uses Layouts will not use your normal template files.

If you are comfortable editing and making changes to the PHP template files then you may not want to use Layouts at all. You can mix and match, use Layouts on some pages and not others, but where you use Layouts you will need to design the whole page with Layouts, changes you make to header.php won't be recognised.

Read about hierarchical layouts to design the repeating header and footer etc. sections of your site here: https://toolset.com/documentation/user-guides/hierarchical-layouts/

#432984

The header/footer in Layouts just really govern the header/footer that appears on the front end. And unfortunately, my enitre site is built at this point using layouts so I don't want to go back to theme files.

However, I do need a meta tag added to the header.php after the opening <head> tag...and the header.php is in the Toolset TwentySixteen integration plugin.

wp-content/plugins/layouts-twentysixteeen/application/theme/view/header.php

Is there any way to copy this file into the child theme to use it and not have to worry about overwriting changes on plugin updates?

Or will I have to make my own custom version of the plugin?

#433153

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

If you just wanted to make sure a certain meta tag is added to the <head> section of your site then you should probably hook into the wp_head action, and echo your meta tag.

Here is an example from the official documentation (https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head) which adds a custom style to the header:

function hook_css() {

	$output="<style> .wp_head_example { background-color : #f1f1f1; } </style>";

	echo $output;

}

I think you should be able to adapt that to your needs, but if you have problems, let me know.

#433160

I had tried a function to hook into wp_head, however, my meta tag for IE compatibility mode ended up at the end of all other head code and it needs to be before everything.

#433171

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Then the only thing I can suggest—other than manually editing the header.php file—is trying the wp_head action with a lower priority (1, or maybe zero, not sure if that is valid) to beat anything else to the punch.

https://developer.wordpress.org/reference/functions/add_action/