Skip Navigation

[Résolu] Change the theme header based on type

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

This topic contains 4 réponses, has 2 voix.

Last updated by jamesG-3 Il y a 7 années et 5 mois.

Assigned support staff: Caridad.

Auteur
Publications
#219969

Hi all - I have a site with 4 distinct types at work: a blog, a magazine, a shop and a video section. When someone goes to the video section I would like that to use a different site header. I have tried a few header plugins but none recognize types, they merely distinguish between pages or posts. Any thoughts?

Thanks!

#220039

Dear James,

You will have to edit the header.php file and use conditionals.

<?php if ( get_post_type() == 'magazine' ) : ?>
SHOW MAGAZINE HEADER
<?php elseif ( get_post_type() == 'video' ) : ?>
SHOW VIDEO HEADER
<?php elseif ( get_post_type() == 'shop' ) : ?>
SHOW SHOP HEADER
<?php else: ?>
SHOW BLOG HEADER
<?php endif; ?>

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#220136

Thanks for the prompt response. The header is presently drawn from this code:

<?php

	do_action('skeleton_header');


?>

This is the correct header for everything apart from post_type single-tv

How would I go about getting the new image in and having it recognize this with the above code?

(apologies if this is more rudimentary than I am seeing)

#220264

Dear James,

Try replacing that line with the following block of code:

<?php if ( get_post_type() == 'single-tv' ) : ?>

  SHOW YOUR CUSTOM HEADER HERE

<?php else : ?>

  <?php
  do_action('skeleton_header');
  ?>

<?php endif; ?>

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

#220460

That worked a treat - thanks so much!!

Le forum ‘Types Community Support’ est fermé à de nouveaux sujets et réponses.