Content Template Repeating Itself – Where to Make Changes?

Ok, I’ve been working on a section of my site for a while, and can’t quite figure out why it isn’t working. I think it’s because I’ve made additions to the content.php template file, when I should’ve been making those same changes somewhere else (maybe base.php?).

Here’s the site:

As you can see, it has one “featured post”, then 4 post thumbnails, then a regular post. You can also see that in the 4 post thumbnail area, all the titles are stacked on top of eachother, which is my problem. I know I’m using the correct CSS now, so the problem has to be with the template file I’m using.

Here’s the code I have in content.php (I’ve added comments to make it easier to follow):

<article <?php post_class(); ?>>

<!-- checks to see if it's the latest post, if so, give it featured styling -->

<?php if ( $wp_query->current_post == 0 && !is_paged() ) { ?>
  <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  <?php get_template_part('templates/entry-meta'); ?>
  <a href="<?php the_permalink(); ?>">
  <?php the_post_thumbnail('homepage-first-thumb'); ?>

  <!-- if it's the 2nd, 3rd, 4th or 5th post in order, display as post box thumbnails -->

<?php } elseif ( $wp_query->current_post == 1 
|| $wp_query->current_post == 2 
|| $wp_query->current_post == 3 
|| $wp_query->current_post == 4 
&& !is_paged() ) { ?>  

<!-- this displays just the thumbnails. I've hidden the content using CSS :nth-child pseudo selector and display: none; -->

<div class="post-boxes">
  <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('homepage-thumb'); ?></a>

  <!-- although the CSS is right for this, all the titles are stacked on top of eachother -->

  <h2><?php the_title(); ?></h2>

<!-- if it's any post after the 5th, display as regular -->

<?php } else { ?>
  <?php if ( has_post_thumbnail() ) {
  } ?>
  <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  <?php get_template_part('templates/entry-meta'); ?>
<?php } ?>
<div class="entry-summary">
<?php if ( $wp_query->current_post == 0 && !is_paged() ) { ?>
  <?php the_content('<br /><br /><button class="btn btn-primary">Read More...</button>'); ?>
<?php } else { ?>
  <?php the_content(); ?>
<?php } ?>

At this point, I have no clue why it’s not working, and I’m assuming it’s how I have the template set up. Should I be making these changes in content.php, or should it be in base.php? If base.php, where should I add it?

Really appreciate any tips, as this has left me stumped!

This is still a CSS issue. Your articles need to be set to display: inline-block;

AWESOME, perfect! Thanks, and sorry for the basic CSS posts!

This topic was automatically closed after 24 hours. New replies are no longer allowed.