‘Alt’ styled comments
-
I’ve recently converted my comments style from WordPress 2.6 to 2.7 formatting by moving the comment layout to the functions.php file as mentioned https://codex.www.ads-software.com/Template_Tags/wp_list_comments here.
The reason for this is simple, I wanted to split my comments into pages.
However while doing this allowed this to work, my comments stopped using their “alt” styles (flipping alignment of text and avatar), which I learnt from following this page. https://www.darrenhoyt.com/2007/08/18/styling-your-wordpress-comments/At first I discovered the lines
<?php foreach ($comments as $comment) : ?>
and
$oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : '';?> <?php endforeach; /* end for each comment */ ?>
would either cause comments not to show up at all, or would just produce a blank screen. (Why isn’t PHP telling me the error?)
Reading around it seems that “alt” is now built into the comments. But yet, my comments do not alternate no matter what I try.This is what is in the functions.php file:
function mytheme_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?> <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> <div id="commentavatar"><?php echo get_avatar( $comment, 64 ); ?></div> <cite></cite> <div class="commentbg"> <div id="actualtext"> <h3><?php comment_author_link() ?></h3> <?php comment_text() ?> <span class="date"><img src="<?php echo get_option('siteurl'); ?>/../layout/comment_time.png" alt="" /> <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_time() ?> on <?php comment_date('F jS, Y') ?></a></span> <?php edit_comment_link('edit',' ',''); ?> </div></div> <?php if ($comment->comment_approved == '0') : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> <?php }?>>
Called via wp_list_comments in the comments.php
What do I have to do to get the .alt style value to be used in ‘odd’ comments again?
EDIT: One more thing, though I am unsure this is possible. Does WP record if a post was made by an unregistered guest? The Admin panel doesn’t seem to differentiate comments any more than just by the name of the poster.
I was wondering (after the above is sorted) if I can make it so all guest posts get labeled as written by a guest rather than what the guest writes as their name, but I can still see that name in the admin panel.
- The topic ‘‘Alt’ styled comments’ is closed to new replies.