0

I am making a basic wordpress theme for the first time and I've finally gotten everything to mostly play nicely. The header displays perfectly fine on every page except the archive page (where blog posts are to go). I've attached the code below, does anybody see a reason why it might be messing up?

It's mainly the header image simply not appearing; navigation is fine, everything works as it should. There just is no image for some reason. It also doesn't show up on the test posts themselves.

archive.php

<div class="container">

<h1><?php single_cat_title();?></h1>

<?php if (have_posts()) : while(have_posts()) : the_post();?>


<div class="card mb-4">
    <div class="card-body">
    <?php if (has_post_thumbnail()):?>

<img src="<?php the_post_thumbnail_url('smallest');?>" class="img-fluid">

<?php endif;?>
    <h3><?php the_title();?></h3>
    <?php the_excerpt();?>
    <a href="<?php the_permalink();?>" class="btn btn-success">Read more</a>
    </div>
    </div>
<?php endwhile; endif;?>

</div>
<?php get_footer();?> ```


Is there any other code that would help you all help me?

Thanks a ton in advance!
2
  • 1
    You’ve included code for everything except the header. How are you outputting the image? Are you using a relative URL? Sep 26 at 17:39
  • There's no get_header() in your code? Your header image displayed on single etc. Just re-check your header.php then. Sep 26 at 22:05
1

You forgot to add get_header() , please try below code.

<?php get_header(); ?>
<div class="container">

<h1><?php single_cat_title();?></h1>

<?php if (have_posts()) : while(have_posts()) : the_post();?>


<div class="card mb-4">
    <div class="card-body">
    <?php if (has_post_thumbnail()):?>

<img src="<?php the_post_thumbnail_url('smallest');?>" class="img-fluid">

<?php endif;?>
    <h3><?php the_title();?></h3>
    <?php the_excerpt();?>
    <a href="<?php the_permalink();?>" class="btn btn-success">Read more</a>
    </div>
    </div>
<?php endwhile; endif;?>

</div>
<?php get_footer();?>
1
  • I must have forgotten to copy that part, sloppy on my end sorry. The problem still persists.
    – perez
    Sep 27 at 23:23

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.