WordPress.org

Support

Support » Themes and Templates » comment template help

comment template help

  • I tried to modify my comments template, but when I uploaded it, it had the comment form under ALL posts on that page, you didn’t get to click the link to go to the comments which is what I want. Can someone please tell me what is wrong with this:
    [code]
    <?php // Do not delete these lines
    if (‘wp-comments.php’ == basename($_SERVER[‘SCRIPT_FILENAME’]))
    die (‘Please do not load this page directly. Thanks!’);
    $req = get_settings(‘require_name_email’);
    if (($withcomments) or ($single)) {
    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
    ?>
    <?php _e(“Enter your password to view comments.”); ?>
    <?php
    return;
    }
    }
    $comment_author = (isset($_COOKIE[‘comment_author_’.$cookiehash])) ? trim($_COOKIE[‘comment_author_’.$cookiehash]) : ”;
    $comment_author_email = (isset($_COOKIE[‘comment_author_email_’.$cookiehash])) ? trim($_COOKIE[‘comment_author_email_’.$cookiehash]) : ”;
    $comment_author_url = (isset($_COOKIE[‘comment_author_url_’.$cookiehash])) ? trim($_COOKIE[‘comment_author_url_’.$cookiehash]) : ”;
    $comments = $wpdb->get_results(“SELECT * FROM $tablecomments WHERE comment_post_ID = ‘$id’ AND comment_approved = ‘1’ ORDER BY comment_date”);
    ?>
    <!– You can start editing here. –>
    <h2 id=”comments”><?php comments_number(__(“Lemons”), __(“1 Lemon”), __(“% Lemons”)); ?>
    <?php if (‘open’ == $post->comment_status) { ?>
    “>»
    <?php } ?>
    </h2>
    <?php if (‘open’ == $post->ping_status) { ?>
    <?php } ?>
    <?php if ($comments) { ?>
    <h1><?php comment_author() ?><h1>
    <p align=”left”><?php comment_date() ?> at <?php comment_time() ?> [ <?php comment_author_email_link() ?> <?php comment_author_url_link() ?> ]
    <p align=”left”><?php comment_text() ?>
    <?php } // end for each comment ?>

    <?php } else { // this is displayed if there are no comments so far ?>
    <?php _e(“No lemons yet. Why don’t you give me one?”); ?>
    <?php } ?>
    <h2 id=”postcomment”><?php _e(“Give me a Lemon”); ?></h2>
    <?php if (‘open’ == $post->comment_status) { ?>
    <form action=”<?php echo get_settings(‘siteurl’); ?>/wp-comments-post.php” method=”post” id=”commentform”>
    <input type=”text” name=”author” id=”author” class=”textarea” value=”<?php echo $comment_author; ?>” size=”28″ tabindex=”1″ />
    <label for=”author”><?php _e(“Name”); ?></label> <?php if ($req) _e(‘(required)’); ?>
    <input type=”hidden” name=”comment_post_ID” value=”<?php echo $id; ?>” />
    <input type=”hidden” name=”redirect_to” value=”<?php echo htmlspecialchars($_SERVER[“REQUEST_URI”]); ?>” />
    <input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”28″ tabindex=”2″ />
    <label for=”email”><?php _e(“E-mail”); ?></label> <?php if ($req) _e(‘(required)’); ?>
    <input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”28″ tabindex=”3″ />
    <label for=”url”><?php _e(“http://”); ?></label>
    <label for=”comment”><?php _e(“Your Comment”); ?></label>

    <?php wp_grins(); ?> <textarea name=”comment” id=”comment” cols=”28″ rows=”4″ tabindex=”4″></textarea>
    <input name=”submit” type=”submit” tabindex=”5″ value=”<?php _e(“Say It!”); ?>” />
    </form>
    <?php } else { // comments are closed ?>
    <?php _e(“Sorry, the comment form is closed at this time.”); ?>
    <?php } ?>
    <?php // if you delete this the sky will fall on your head
    }
    ?>
    [/code]

Viewing 1 replies (of 1 total)
  • Use the backtick character to wrap SMALL bits of code in the forum. It’s the character on the same key as the tilde ( ~ ).
    Also, it’s much appreciated if you post large blocks of code somewhere else and provide a link to it.

Viewing 1 replies (of 1 total)
  • The topic ‘comment template help’ is closed to new replies.
Skip to toolbar