• jlmcgowan

    (@jlmcgowan)


    I hope someone can help me. I want my comments box to always be visible under each post. However, it’s not showing up. It only reads “# Comments”

    Here’s the coding in my themes comments.php I have no idea what to change to get the comments box to show up. I have set it so that Commentors do not have to register or be logged into comment…Which coding is causing the comments box to not be visible under the post?

    <?php // Do not delete these lines
    if (‘comments.php’ == basename($_SERVER[‘SCRIPT_FILENAME’])) die (‘Please do not load this page directly. Thanks!’);
    if (!empty($post->post_password)) { // if there’s a password
    if ($_COOKIE[‘wp-postpass_’ . COOKIEHASH] != $post->post_password) { // and it doesn’t match the cookie
    ?>

    <h2><?php _e(‘Password Protected’); ?></h2>
    <p><?php _e(‘Enter the password to view comments.’); ?></p>

    <?php return;
    }
    }

    /* This variable is for alternating comment background */

    $oddcomment = ‘alt’;

    ?>

    <!– You can start editing here. –>

    <?php if ($comments) : ?>
    <h3 id=”comments”><?php comments_number(‘No Responses’, ‘One Response’, ‘% Responses’ );?> to “<?php the_title(); ?>”</h3>

    <ol class=”commentlist”>
    <?php foreach ($comments as $comment) : ?>

    <li class=”<?php echo $oddcomment; ?>” id=”comment-<?php comment_ID() ?>”>

    <div class=”commentmetadata”>
    <?php comment_author_link() ?>, <?php _e(‘on’); ?> ” title=””><?php comment_date(‘F jS, Y’) ?> <?php _e(‘at’);?> <?php comment_time() ?> <?php _e(‘Said:’); ?> <?php edit_comment_link(‘Edit Comment’,”,”); ?>
    <?php if ($comment->comment_approved == ‘0’) : ?>
    <?php _e(‘Your comment is awaiting moderation.’); ?>
    <?php endif; ?>
    </div>

    <?php comment_text() ?>

    <?php /* Changes every other comment to a different class */
    if (‘alt’ == $oddcomment) $oddcomment = ”;
    else $oddcomment = ‘alt’;
    ?>

    <?php endforeach; /* end for each comment */ ?>

    <?php else : // this is displayed if there are no comments so far ?>

    <?php if (‘open’ == $post->comment_status) : ?>
    <!– If comments are open, but there are no comments. –>
    <?php else : // comments are closed ?>

    <!– If comments are closed. –>
    <p class=”nocomments”>Comments are closed.</p>

    <?php endif; ?>
    <?php endif; ?>

    <?php if (‘open’ == $post->comment_status) : ?>

    <h3 id=”respond”>Leave a Reply</h3>

    <?php if ( get_option(‘comment_registration’) && !$user_ID ) : ?>
    <p>You must be /wp-login.php?redirect_to=<?php the_permalink(); ?>”>logged in to post a comment.</p>

    <?php else : ?>

    <form action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php” method=”post” id=”commentform”>
    <?php if ( $user_ID ) : ?>

    <p>Logged in as /wp-admin/profile.php”><?php echo $user_identity; ?>. /wp-login.php?action=logout” title=”Log out of this account”>Logout ?</p>

    <?php else : ?>

    <p><input type=”text” name=”author” id=”author” value=”<?php echo $comment_author; ?>” size=”40″ tabindex=”1″ />
    <label for=”author”><small>Name <?php if ($req) echo “(required)”; ?></small></label></p>

    <p><input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”40″ tabindex=”2″ />
    <label for=”email”><small>Mail (will not be published) <?php if ($req) echo “(required)”; ?></small></label></p>

    <p><input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”40″ tabindex=”3″ />
    <label for=”url”><small>Website</small></label></p>

    <?php endif; ?>

    <!–<p><small>XHTML: <?php _e(‘You can use these tags:’); ?> <?php echo allowed_tags(); ?></small></p>–>

    <p><textarea name=”comment” id=”comment” cols=”60″ rows=”10″ tabindex=”4″></textarea></p>

    <p><input name=”submit” type=”submit” id=”submit” tabindex=”5″ value=”Submit Comment” />
    <input type=”hidden” name=”comment_post_ID” value=”<?php echo $id; ?>” />
    </p>

    <?php do_action(‘comment_form’, $post->ID); ?>

    </form>

    <?php endif; // If registration required and not logged in ?>

    <?php endif; // if you delete this the sky will fall on your head ?>

Viewing 10 replies - 1 through 10 (of 10 total)
  • I am having the same problem — Can someone PLEASE answer this questions. I’ve not found the answer in any forum. The couple of things suggested were not clear and did not work when tried. Thank you for any help anyone can give. ??

    Hi

    By default comments display only when WP is displaying a single post with the single.php theme template. To have them appear on your main posts page you mist edit the main posts page template, not comments.php

    Which file is used on the main posts page is theme-dependent, and the defaults can be overriden if there is a static home page. However, in most themes it will be either home.php or if that file does not exist, most likely index.php

    The code that needs to be added is

    <?php
      $withcomments = "1";
      comments_template();
    ?>

    Where the code goes is also theme-dependent. I suggest placing it just before the code that looks something like this

    </div>
    <?php endwhile ?>

    If they are not displaying in the right place you may find you need to put it before the </div> preceding the one I mentioned. Note you are not adding an additional </div>, you are working with the one(s) already there.

    typo in the above

    should be this

    </div>
    <?php endwhile; ?>

    I have this issue. No way to comment unless you actually click on the individual blog title, then at the bottom of the post is the comment box. How do I add the comment box to the bottom of all my posts?
    You can see what I mean here:

    https://www.eastsidepatch.com/

    (I am running Thesis with the Type Pad skin)

    Please can anyone help me – I am going crazy. I love my new blog but this isue will kill it!
    ESP.

    See the reply by stvwlf above.

    So I am in the typogrid-home php looking for the place to put the:

    <?php
    $withcomments = “1”;
    comments_template();
    ?>
    Text..the problem is, or I am blind I do not see the </div>
    <?php endwhile ?> anywhere? Can someone help me as to where this code needs to be positioned?

    Here is my code…

    <?
    php
    global $post;
    $typoptions = get_option(‘typogrid_options’);

    if ($typoptions[‘lnkad1’] == ”)
    $typoptions[‘lnkad1’] = ‘#’;

    if ($typoptions[‘lnkad2’] == ”)
    $typoptions[‘lnkad2’] = ‘#’;

    if ($typoptions[‘lnkad3’] == ”)
    $typoptions[‘lnkad3’] = ‘#’;

    function string_limit_words($string, $word_limit, $section) {
    $words = explode(‘ ‘, $string, ($word_limit +1));
    if(count($words) > $word_limit) {
    array_pop($words);
    if ($section == ‘latest’) {
    $words[25] .= ‘…’;
    } elseif ($section == ‘popular’) {
    $words[45] .= ‘…’;
    }
    }
    return implode(‘ ‘, $words);
    }

    ?>
    <div id=”content” class=”hfeed”>
    <h3 class=”typoblock <?php echo $typoptions[‘colorfeatured’]; ?>”><span><?php if ($typoptions[‘titlefeatured’] == ”) { echo ‘Featured’; } else { echo $typoptions[‘titlefeatured’]; } ?></span></h3>
    <div class=”typoline”></div>
    <div id=”featured”>
    <?php
    if ($typoptions[‘catfeatured’] == ”) {
    $catfeat = ‘featured’;
    } else {
    $catfeat = $typoptions[‘catfeatured’];
    }

    if ($typoptions[‘numfeatured’] == ”) {
    $numfeatposts = 3;
    } else {
    $numfeatposts = $typoptions[‘numfeatured’];
    }

    query_posts(‘category_name=’.$catfeat.’&showposts=’.$numfeatposts);
    $feat_post_count = 0;

    while (have_posts()) {
    the_post();
    $feat_post_count++;

    $feat_image_url = get_post_meta($post->ID, ‘thesis_post_image’, true);

    ?>
    <div class=”post post_box” id=”post-<?php echo $post->ID; ?>”>
    <div class=”featured_image” style=”background:url(‘<?php echo $feat_image_url; ?>’) no-repeat;”>
    <div class=”headline_featured”>
    <h2 class=”entry-title”>” rel=”bookmark” title=”Permanent link to <?php the_title(); ?>”><?php the_title(); ?></h2>
    </div>
    </div>
    <div class=”headline_area”>
    <p class=”headline_meta”><abbr class=”published” title=”2009-06-06″><?php the_time(‘F jS, Y’); ?></abbr> · <span>” rel=”nofollow”><?php comments_number(‘0 Comments’,’1 Comment’,’% Comments’); ?></span></p>
    </div>
    <div class=”format_text entry-content”>
    <?php the_excerpt(); ?>
    </div>
    </div>
    <?php
    }
    ?>
    </div><!–end featured–>
    </div><!–end content–>

    <div id=”popular”>
    <h3 class=”typoblock <?php echo $typoptions[‘colorpopular’]; ?>”><span><?php if ($typoptions[‘titlepopular’] == ”) { echo ‘Popular’; } else { echo $typoptions[‘titlepopular’]; } ?></span></h3>
    <div class=”typoline”></div>
    <?php
    if ($typoptions[‘catpopular’] == ”) {
    $catpop = ”;
    } else {
    $catpop = $typoptions[‘catpopular’];
    }

    $typocatidpop = get_cat_ID( $catpop );
    if ( $typocatidpop != ” ) {
    $typocatlink = get_category_link( $typocatidpop );
    } else {
    $typocatlink =’#’;
    }

    query_posts(‘category_name=’.$catpop.’&showposts=2′);
    $popular_post_count = 0;

    while (have_posts()) {
    the_post();
    $popular_post_count++;

    $popular_image_url = get_post_meta($post->ID, ‘thesis_post_image’, true);
    $popular_image[‘alt’] = get_post_meta($post->ID, ‘thesis_post_image_alt’, true);

    if ($popular_image_url != ”) {
    $popular_local_path = explode($_SERVER[‘SERVER_NAME’], $popular_image_url);
    $popular_image[‘url’] = THESIS_SCRIPTS_FOLDER . ‘/thumb.php?src=’ . $popular_local_path[1] . ‘&w=209&h=145&zc=0&q=100’;
    }

    $popular_excerpt = get_the_excerpt();
    ?>
    <div class=”post post_box <?php if ($popular_post_count == 2) echo ‘ last’; ?>” id=”post-<?php echo $post->ID; ?>”>
    <div class=”headline_area”>
    <?php if ($popular_image[‘url’] != ”) { ?>
    <img src=”<?php echo $popular_image[‘url’]; ?>” alt=”<?php echo $popular_image[‘alt’]; ?>”/>
    <?php } ?>
    <h2 class=”entry-title”>” rel=”bookmark” title=”Permanent link to <?php the_title(); ?>”><?php the_title(); ?></h2>
    <p class=”headline_meta”><abbr class=”published” title=”2009-06-06″><?php the_time(‘F jS, Y’); ?></abbr> · <span>” rel=”nofollow”><?php comments_number(‘0 Comments’,’1 Comment’,’% Comments’); ?></span></p>
    </div>
    <div class=”format_text entry-content”>
    <p><?php echo string_limit_words($popular_excerpt,45,’popular’); ?> ” rel=”bookmark” class=”typoreadmore<?php echo $typoptions[‘colorpopular’]; ?>”>More</p>
    </div>
    </div>

    <?php
    $popular_image[‘url’] = ”;
    $popular_image[‘alt’] = ”;
    }
    ?>
    </div><!–end popular–>

    <div id=”featured_nav”>
    <div class=”prev_next”>
    <?php if ($numfeatposts != 1) { ?>
    <p id=”typoprev” class=”previous floated”>Previous</p>
    <p id=”typonext” class=”next”>Next</p>
    <?php } ?>
    </div>
    <div class=”popular_section_meta”>
    <p class=”typogrid_section_meta”>“>browse category</p>
    </div>
    </div><!–end featured_nav–>

    </div><!–end content_box–>
    </div><!–end page–>
    </div><!–end content_area–>

    <div id=”welcome_area” class=”full_width”>
    <div class=”page”>
    <div id=”welcome”>
    <div id=”welcome_txt”>
    <p class=”typogrid_headline”><?php if ($typoptions[‘titlewelcome’] == ”) { echo ‘Welcome’; } else { echo $typoptions[‘titlewelcome’]; } ?></p>
    <div class=”format_text”>
    <p class=”middleblock”><?php if ($typoptions[‘txtwelcome’] == ”) { echo ‘Welcome visitors to your site with a warm and friendly message. You can change the heading and the text for this section in the Typogrid Options page.’; } else { echo $typoptions[‘txtwelcome’]; } ?></p>
    </div>
    </div>

    <div id=”typogrid_ads_home”>
    <ul id=”ads_125x125″>

    • <?php if ($typoptions[‘imgad1’] != ”) { echo ‘<img src=”‘.THESIS_CUSTOM_FOLDER.’/images/ads/’.$typoptions[‘imgad1’].'” />‘; } else { echo ‘<p><span class=”txt_white”>Ad Spot</span>
      125 x 125</p>’; } ?>
    • <?php if ($typoptions[‘imgad2’] != ”) { echo ‘<img src=”‘.THESIS_CUSTOM_FOLDER.’/images/ads/’.$typoptions[‘imgad2’].'” />‘; } else { echo ‘<p><span class=”txt_white”>Ad Spot</span>
      125 x 125</p>’; } ?>
    • <?php if ($typoptions[‘imgad3’] != ”) { echo ‘<img src=”‘.THESIS_CUSTOM_FOLDER.’/images/ads/’.$typoptions[‘imgad3’].'” />‘; } else { echo ‘<p><span class=”txt_white”>Ad Spot</span>
      125 x 125</p>’; } ?>
    • </div><!–end typogrid_ads_home–>
      </div><!–end welcome–>
      </div><!–end page–>
      </div><!–end welcome_area–>

      <div id=”latest_area” class=”full_width”>
      <div class=”page”>
      <div id=”latest”>
      <h3 class=”typoblock <?php echo $typoptions[‘colorlatest’]; ?>”><span><?php if ($typoptions[‘titlelatest’] == ”) { echo ‘Latest’; } else { echo $typoptions[‘titlelatest’]; } ?></span></h3>
      <div class=”typoline”></div>
      <?php
      $typocatidfeat = get_cat_ID( $catfeat );
      $latestcatexclude = array($typocatidfeat,$typocatidpop);
      query_posts(array(‘category__not_in’=>$latestcatexclude,’showposts’=>4));
      $latest_post_count = 0;

      while (have_posts()) {
      the_post();
      $latest_post_count++;

      $latest_image_url = get_post_meta($post->ID, ‘thesis_post_image’, true);
      $latest_image[‘alt’] = get_post_meta($post->ID, ‘thesis_post_image_alt’, true);

      if ($latest_image_url != ”) {
      $latest_local_path = explode($_SERVER[‘SERVER_NAME’], $latest_image_url);
      $latest_image[‘url’] = THESIS_SCRIPTS_FOLDER . ‘/thumb.php?src=’ . $latest_local_path[1] . ‘&w=209&h=145&zc=0&q=100’;
      }

      $latest_excerpt = get_the_excerpt();
      ?>
      <div class=”latest_box<?php if ($latest_post_count == 4) echo ‘ last’; ?>” id=”post-<?php echo $post->ID; ?>”>
      <div class=”headline_area”>
      <?php if ($latest_image[‘url’] != ”) { ?>
      <img src=”<?php echo $latest_image[‘url’]; ?>” alt=”<?php echo $latest_image[‘alt’]; ?>”/>
      <?php } ?>
      <h2 class=”entry-title”>” rel=”bookmark” title=”Permanent link to <?php the_title(); ?>”><?php the_title(); ?></h2>
      <p class=”headline_meta”><abbr class=”published” title=”2009-06-06″><?php the_time(‘F jS, Y’); ?></abbr> · <span>” rel=”nofollow”><?php comments_number(‘0 Comments’,’1 Comment’,’% Comments’); ?></span></p>
      </div>

      <div class=”format_text entry-content”>
      <p><?php echo string_limit_words($latest_excerpt,25,’latest’); ?> ” rel=”bookmark” class=”typoreadmore<?php echo $typoptions[‘colorlatest’]; ?>”>More</p>
      </div>
      </div>
      <?php
      $latest_image[‘url’] = ”;
      $latest_image[‘alt’] = ”;
      }
      ?>
      </div><!–end latest–>
      <?php
      $typoarchivelnk = $typoptions[‘lnkarchives’];
      if ( $typoarchivelnk == ” )
      $typoarchivelnk = ‘#’;
      ?>
      <div id=”latest_nav”>
      <div class=”archive_section_meta”>
      <p class=”typogrid_section_meta”>“>view archives</p>
      </div>

    Please don’t post huge chunks of code here. For larger blocks of code, use the WordPress pastebin. It makes life easier for everyone.

    I have tried this code.

    <?php
    $withcomments = “1”;
    comments_template();
    ?>

    And it is working.

    But I want to show ONLY the comment box under each post, not the actual comments. To get the comments the users can click “# Comments”.

    Any ideas?

    bump!

    stywlf, when you say “to have them appear on your main posts page you mist edit the main posts page template, not comments.php” what is the name of the “main posts page template”? Is it page.php you are referring to?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Comment Box Not Showing Under Posts’ is closed to new replies.