[Resolved] Custom header and footer to archive pages
This support ticket is created 5 years, 1 month 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
We need to create a custom page template for taxonomy pages where we have a specific header and footer (we need this because some catagories will have the header in english and others in italian).
We saw that the content template can do that but the header and footer are repeating for every piece of content in the loop.
I don't understand from your question how you are creating your custom header and footer.
Are you editing the theme PHP template files?
In particular I'm puzzled by "we saw that the content template can do that", because Content Templates only replace what is output by the_content() in the PHP templates, and are not used for headers or footers.
Hi Nigel,
for example, for the PAGES of the site we created a content template that holds also the header and footer in the content area so since the template holds that data we can easily create a template with a different header or footer.
This doesn't work for the archive pages because if we build a content template to be applied to a taxonomy page and place the DIV of header and footer, this repeats for every element of the page.
So you edited the theme template files so that they output no header and no footer, so the content template takes up the whole page because there is no conventional header or footer, and your content template can include a fake-header and fake-footer, which you can change as required.
I'll repeat that content templates simply replace what is output by the_content() function in your theme PHP files.
On an archive, the_content() is output for every result of the archive, so, yes, if your template includes a fake header and footer, these will be output for every item in the archive loop.
You could edit the relevant archive.php template and insert a specific content template before the loop and another specific content template after the loop, and then design those templates using Toolset how you like.
Thanks Nigel, but in this way I get the result of a custom header and footer but I cannot have a specific header or footer depending on the taxonomy, since the archive.php file still remain a unique file.
How can I achieve to get a specific archive file depending on taxonomy? Or a specific template file depending on taxonomy to be recalled by the unique archive.php file?
archive.php is the most generic template for archives if there isn't a more specific one that matches the page being loaded.
So if you wanted a special template to only be used for the 'red' term of the 'colour' taxonomy then you could create a template file taxonomy-colour-red.php which would be used in place of the next most specific template available for that page.
An alternative would be to add conditional shortcodes to your templates where you insert the header and footer to show different content according to the taxonomy term of the current archive, for example, although using the built-in template hierarchy would be more efficient if you are already editing the theme template files.