• Hello there,

    As the topic title states I’ve got a problem with the comments. Problem is simple: the same comments turns up on every post. Not good, eh.

    So far the only thing I can imagine would screw it up would be… some of the other php-codes in single.php. As a rookie, I really don’t know, but could it be some issue with the foreach command somehow? Anyone able to point me in the right direction?

    Any help much appriciated.

    PS: Installed the Disqus-plugin, works fine, but same problem – same comments.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Have you tried:

    – deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    – switching to the Twenty Ten theme to rule out any theme-specific problems.

    resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems.

    Thread Starter pmbs

    (@pmbs)

    Thanks for the tips. Probably should have done those before asking, huh.

    Anyhow, problem lies within the template then. Because with Twenty Ten comments would stay with the unique post (Disqus had some problems loading on this theme, allthough).

    So template problem.. now what? ??

    Unless you are really comfortable working with PHP and HTML, I’d suggest looking for another theme.

    Thread Starter pmbs

    (@pmbs)

    Yea, well, thing is this is my own-developed theme. Just have to try to figure out where the PHP-conflict could be.

    Still, if anyone else did run into the same; yell out.

    Thread Starter pmbs

    (@pmbs)

    <?php
    $args = array( 'numberposts' => 9, 'order'=> 'DESC', 'orderby' => 'post_date' );
    $postslist = get_posts( $args );
    foreach ($postslist as $post) :  setup_postdata($post); ?>
    <div id="hoyrebar-tittel-wrap">
    <a href="<?php the_permalink() ?>"><?php if (strlen($post->post_title) > 27) {
    echo substr(the_title($before = '', $after = '', FALSE), 0, 27) . '..'; } else {
    the_title();
    } ?>
            <?php endforeach; ?>

    This is the code that screws up the comments (removing it – comments works fine).
    Anyone can rewrite this so it won’t collide?

    try and save the $post object into a $temp variable, for instance, before your code section, and restore it after:

    <?php $temmp = $post; //save $post object;
    $args = array( 'numberposts' => 9, 'order'=> 'DESC', 'orderby' => 'post_date' );
    $postslist = get_posts( $args );
    foreach ($postslist as $post) :  setup_postdata($post); ?>
    <div id="hoyrebar-tittel-wrap">
    <a href="<?php the_permalink() ?>"><?php if (strlen($post->post_title) > 27) {
    echo substr(the_title($before = '', $after = '', FALSE), 0, 27) . '..'; } else {
    the_title();
    } ?>
            <?php endforeach;
    $post = $temp; //restore $post object; ?>
    Thread Starter pmbs

    (@pmbs)

    alchymyth, thanks alot! Working as a charm! ??

    Allthough, now, after I’ve changed my permalinks to %posttitle% Disqus-plugin wont load comments.. Arrgh. Another thing to figure out.

    hungit

    (@hungit)

    Since 3.0, you only need call <?php wp_reset_postdata(); ?> after your looping.

    Hope this help ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Same comments on every post’ is closed to new replies.