• Resolved miromiro

    (@miromiro)


    Hi,

    I am still new at WP (and hopeless at PHP) so this is driving me nuts. I have created a category template – which works, except where there are multiple entries in that category, WP repeats the same post & title for each entry.

    Example: http://www.psnetwork.org.nz/blog/?cat=7

    I relaise it is probably a simple tweak to the code, but my efforts to date have just resulted in chaos.

    Any help/suggestions greatly appreciated.

    Cheers,
    /J

Viewing 4 replies - 1 through 4 (of 4 total)
  • Looks like you forgot or mangled a part of The_Loop.

    If you don’t see what you’re after at the link above, go ahead and post your category template’s code at http://wordpress.pastebin.ca/. Then reply back here with the link to the pastebin and we’ll have a look.

    Thread Starter miromiro

    (@miromiro)

    Thanks for the help Handy,

    I’m pretty sure it will be something basic (read: stupid) that I have forgotton or ommitted, but I just can’t track it.

    I have pasted the code here: http://wordpress.pastebin.ca/183643

    Cheers,

    http://wordpress.pastebin.ca/183743

    Fixes to the template:

    1. Removed this line:

    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>

    This is what caused duplicates of the same post to appear; it continually resets the post object to the first one in $posts. As you don’t even use the_date() in the template, there’s no reason to work around it (even so, it’s a bad way to do that).

    2. Moved this:

    <?php /* If this is a category archive */ if (is_category()) { ?>
    <h1 class="pagetitle">Archive for the <?php echo single_cat_title(); ?> category</h1>
    <?php } ?>

    above the post loop so it will only display once.

    Thread Starter miromiro

    (@miromiro)

    Thanks Kafkaesqui (& Handy),

    It works a treat now. I appreciate the assistance.

    Cheers,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Post titles repeating in category template’ is closed to new replies.