0

I have a problem in my logic, I want to display a different header of the index until I could do it now I want to display the name of each page or category through this code, but the problem is that in the category this is taking the name of the last post and not the name of the category BLOG an example.

 <!-- estilo do header -->
<?php if ( is_front_page() != is_home() ): ?>

<header id="masthead" class="site-header" role="banner" >

<?php elseif (is_home() ) : ?>
<header id="masthead" class="site-header" role="banner" style="width: 100%; height: 300px;background-color: black;">

<h1 class="text-white">

<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?>

</h1>
<?php else : ?>
<header id="masthead" class="site-header" role="banner" style="width: 100%; height: 300px;background-color: black;">

<h1> <?php the_title()?> </h1>

<?php endif; ?>
<!-- header estilo-->

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.