Show same comments on all posts
-
Im currently making a template and the comment template show the same comment on all blog posts why ? Im using bootstrap if some one want to know.
Code in functions.php
function mytheme_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; extract($args, EXTR_SKIP); $avatar = preg_replace('#.*src="([^\"]+)".*#', '\1', get_avatar($comment,$size='48')); ?> <div class="media" id="comment-<?php comment_ID() ?>"> <div class="media-left"> <a href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)) ?>"> <img class="media-object img-rounded" src="<?php echo $avatar; ?>" style="width:42px;"> </a> </div> <div class="media-body"> <h5 class="media-heading"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?>, <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?></h5> <?php comment_text() ?> <p> <?php edit_comment_link(__('(Redigera) - '),' ','') ?> <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> </p> </div> </div> <?php }
My short-comments.php
<?php // Do not delete these lines if (!empty($_SERVER['SCRIPT_FILENAME']) && 'short-comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); if ( post_password_required() ) { ?> <p class="no-comments">This post is password protected. Enter the password to view comments.</p> <?php return; } ?> <!-- You can start editing here. --> <?php if ( have_comments() ) : ?> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading"> <?php comments_number( 'Inga kommentarer', '1 Kommentar', '% kommentarer' ); ?> </div> <div class="panel-body"> <?php wp_list_comments("callback=mytheme_comment");?> </div> </div> </div> <?php endif; ?> <!-- FORM --> <?php if ( comments_open() ) : ?> <div class="col-md-12 blog-comment"> <h5>L?mna en kommentar <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?> <br><p> Du m?ste<a href="<?php echo wp_login_url( get_permalink() ); ?>"> logga in</a> f?r att kommentera!</p> <?php else : ?> </h5> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post"> <?php if ( is_user_logged_in() ) : ?> <div class="form-group"> <p> Inloggad som: <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account"> Logga ut</a></p> </div> <div class="form-group"> <textarea rows="10" name="comment" id="comment" class="form-control"></textarea> </div> <button type="submit" id="submit" tabindex="5" class="btn btn-dark-green"> Skriv kommentar</button> <?php comment_id_fields(); ?> <?php do_action('comment_form', $post->ID); ?> <?php else : ?> <div class="form-group"> <input type="text" class="form-control" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" placeholder="Namn"> </div> <div class="form-group"> <input type="email" class="form-control" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" placeholder="Ange email"> </div> <div class="form-group"> <input type="text" class="form-control" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" placeholder="Webbplats"> </div> <div class="form-group"> <textarea rows="10" name="comment" id="comment" class="form-control"></textarea> </div> <button type="submit" id="submit" tabindex="5" class="btn btn-dark-green">Skriv kommentar</button> <?php comment_id_fields(); ?> <?php do_action('comment_form', $post->ID); ?> <?php endif; ?> </form> </div> <?php endif; // If registration required and not logged in ?> <?php endif; // if you delete this the sky will fall on your head ?>
In single.php
<?php comments_template("/short-comments.php"); ?>
- The topic ‘Show same comments on all posts’ is closed to new replies.