Faisal
Faisal

Reputation: 175

the title of my wordpress post changes with every new post

I did a lot of wordpress sites before but this is the strangest thing that ever happened to me.

When i published the first post everything looks okay when i post another post the title and the thumbnail of the old post changes to be like the second one.

my site feedbaks.com

and that's a part of the index.php

<?php get_header(); ?>
<div id="body">
    <div class="content-container">
        <?php 
        if (have_posts()) :
        while (have_posts()) : ?>
        <?php 
        // check if the post has a Post Thumbnail assigned to it.
            if ( has_post_thumbnail() ) {
            the_post_thumbnail();
            } 
        ?>
        <div class="content">
        <h2 id="post-title">
        <a href="<?php the_permalink() ?>" rel="bookmark">
        <?php
            $cats=get_the_category();
            echo $cats[0]->cat_name;
            ?> : <?php the_title(); ?></a></h2>
        <div class="comments"><?php the_post(); comments_popup_link('0', '1', '%'); ?></div>

please help me

thanks in advance

Upvotes: 1

Views: 80

Answers (1)

s_ha_dum
s_ha_dum

Reputation: 2850

Your Loop is missing a function. You need the_post(), like so:

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

I believe that addition will solve your problem.

[edit] Actually, the_post() isn't missing. It is just much too late in the function. You don't run that until just before the comments.

Upvotes: 1

Related Questions