• So, trackbacks are showing up as comments on my site. I found some info on this that shows how to fix the problem, but the problem is my theme is already set up (supposedly) to work. I think the designer must have forgotten something simple. Is there an obvious place to start looking for why this would be happening?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Find this in your theme’s comments.php
    wp_list_comments();

    Change to..
    wp_list_comments('type=comment');

    Thread Starter nickaster

    (@nickaster)

    Thanks man!

    Unfortunately looks like the designer put some custom code in there so I can’t figure it out. I’m just going to have to wait. I do have a question though – trackbacks also show up as “comments” in the back-end of WP, with nothing other than my intuition telling me that they are trackbacks and not comments (the […] is the give-a-way).

    Is that normal?

    Yes i believe so…

    What’s different in your file, i can help you with it, it’s proberly just a custom callback or something, nothing we can’t handle… ??

    Thread Starter nickaster

    (@nickaster)

    Well, thanks! First of all, here’s the a relevant page on the site: https://www.triplepundit.com/2009/07/wine-tastings-crab-cakes-and-great-scenery-is-this-why-amtrak-is-rising/

    Notice that at the top it correctly states that there are 3 comments, but later it says 4 comments, with only 3 showing. One of those 4 is in fact a trackback which is not showing in its little tab.

    The line you mention above has been changed to:

    count($trackbacks) > 0) wp_list_comments('type=comment&callback=sdac_comment'); ?>

    The “sdac” stuff is custom code from the designer and I’ve got no idea where it’s coming from. Then again I’m really new to wordpress so maybe it’s obvious to you?

    Yes it’s just a custom callback, you’ll find the related code in the theme functions.php.

    Can you post more of the surrounding code, the above has an uneven amount of closing brackets so there must be more code along with that…

    Thread Starter nickaster

    (@nickaster)

    Of course, thanks a mil. At the risk of posting too much, here’s the whole thing:

    <?php
    
    	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    		die ('Please do not load this page directly. Thanks!');
    
    	if ( post_password_required() ) { ?>
    		<p class="nocomments">This post is password protected. Enter the password to view comments.</p>
    	<?php
    		return;
    	}
    
    	$trackbacks = $comments_by_type['pings'];
    ?>
    
    	<div id="comments">
    		<ul>
    			<li><a href="#commentsList"><span>Comments (<?php echo count($comments)-count($trackbacks);?>)</span></a></li>
           	 	<li><a href="#trackbacksList"><span>Trackbacks (<?php echo count($trackbacks);?>)</span></a></li>
    		</ul>
    
    			<?php if (pings_open()) : ?>
    
    			<div id="trackbacksList">
    				<ol id="trackbackList">
    					<?php if ($trackbacks) : $trackbackcount = 0; ?>
    						<?php foreach ($trackbacks as $comment) : ?>
    						<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
    							<div class="commentBox">
    								<p class="commentMeta"><?php comment_time('F m, Y');?> at <?php comment_time('G:i a T');?> | <?php comment_author_link();?> writes:</p>
    								<p><?php comment_text(); ?></p>
    							</div>
    						</li>
    						<?php endforeach;?>
    
    					<?php else : ?>
    
    						<li class="odd">No trackbacks yet</li>
    
    					<?php endif; ?>
    				</ol>
    
    			<div class="clearjz"></div>
    		</div>	
    
     		<?php endif;?>
    
    		<?php if ( have_comments() ) : ?>
    
    			<div id="commentsList">
    				<h2 class="articles">Comments</h2>
    				<ol id="commentList">
    					<?php if ($comments && count($comments) - count($trackbacks) > 0) wp_list_comments('type=comment&callback=sdac_comment'); ?>
    				</ol>
    				<?php if (show_posts_nav()) : ?>
    					<div class="navigation">
    						<div class="alignleft"><?php previous_comments_link() ?></div>
    						<div class="alignright"><?php next_comments_link() ?></div>
    					</div>
    				<?php endif;?>
    
     		<?php else : ?>
    
    			<?php if ( comments_open() ) : ?>
    				<div id="commentsList">
    					<ol id="commentList" class="noComments">
    						<li>No Comments - Be the first to comment!</li>
    					</ol>
    					<div class="clearjz"></div>
    
    			<?php else : // comments are closed ?>
    
    				<div id="commentsList">
    					<ol id="commentList">
    						<li>Comments are Closed</li>
    					</ol>
    					<div class="clearjz"></div>
    				</div>	
    
    			<?php endif; ?>
    		<?php endif; ?>
    
    		<?php if ( comments_open() ) : ?>
    
    			<div id="respond">
    				<h2 class="articles"><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h2>
    				<div class="cancel-comment-reply">
    				<p><?php cancel_comment_reply_link(); ?></p>
    			</div>
    
    		<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
    
    			<p>You must be <a href="<?php echo wp_login_url( get_permalink() ); ?>">logged in</a> to post a comment.</p>
    
    		<?php else : ?>
    
    			<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentForm">
    
    			<?php if ( is_user_logged_in() ) : ?>
    
    				<p>Logged in as <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">Log out &raquo;</a></p>
    				<p><textarea name="comment" class="text" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
    
    			<?php else : ?>
    
    <div id="ways">There are 3 ways to comment on 3P</div>
    
    				<div id="commentOptions">
    
    					<div class="commentOption">
    						<p><strong>1. Guests</strong></p>
    						<a id="respond">Comment Instantly<br /> Below:</a>
    					</div>
    
    					<div class="commentOption">
    						<p><strong>2. Facebook Users</strong></p>
    						<p>Login to your Facebook account</p>
    						<?php widget_FacebookConnector(array());?>
    					</div>
    
    					<div class="commentOption lastOption">
    						<p><strong>3. Members</strong></p>
    						<p><a target="_blank" href="<?php bloginfo('url');?>/wp-login.php?action=register">Register</a> for an account or <a target="_blank" href="<?php bloginfo('url');?>/wp-login.php">login</a>.</p>
    					</div>
    				</div>
    
    			<div id="commentsLeft">
    				<p>
    					<label for="author">Name <?php if ($req) echo "(required)"; ?></label>
    					<input type="text" class="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
    				</p>
    
    				<p>
    					<label for="email">Email <?php if ($req) echo "(required)"; ?></label>
    					<input type="text" class="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
    				</p>
    
    				<p>
    					<label for="url">URL</label>
    					<input type="text" class="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
    				</p>
    			</div>
    			<div id="commentsRight">
    				<p>
    					<label>Comment:</label>
    					<textarea name="comment" class="text" id="comment" cols="100%" rows="10" tabindex="4"></textarea>
    				</p>
    			</div>
    
    			<?php endif; ?>
    
    			<p id="subscribeComments"><a href="#"><img src="<?php bloginfo('template_url');?>/images/icon-rss.gif" /></a> <a href="#">Subscribe to Comments</a></p>
    			<p id="submitComment"><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /></p>
    			<?php comment_id_fields(); ?>
    			<?php do_action('comment_form', $post->ID); ?>
    		</form>
    		<div class="clearjz"></div>
    	</div>	
    
    <?php endif; // If registration required and not logged in ?>
    </div>
    
    <?php endif; // if you delete this the sky will fall on your head ?>
    </div>

    Ok and what you like to do with the pings/trackbacks?

    Remove them completely or move them to a different area of the page?

    Thread Starter nickaster

    (@nickaster)

    Right… well, there’s supposed to be a nifty little section in a tab which would display them essentially the same way as comments, but yes, in a different area. You can see where it’s supposed to be here:

    https://www.triplepundit.com/2009/07/wine-tastings-crab-cakes-and-great-scenery-is-this-why-amtrak-is-rising/

    (note the two tabs)

    I think the problem relates to this.
    $trackbacks = $comments_by_type['pings'];

    Unless another file is populating $comments_by_type

    Then your trackback checks in the above code will be looking at an empty variable..

    Perhaps there’s something more in the functions file, i can see there is a custom callback at least…

    Can you paste the functions file code into a pastebin please…
    https://wordpress.pastebin.com/

    Thread Starter nickaster

    (@nickaster)

    You got it. Thanks a million…. that pastebin thing is pretty cool. Hope I did it right:

    https://wordpress.pastebin.com/m39e586a1

    Yeah i’m not sure how that code is suppose to function, it’s essentially a variant that’s used in other themes such as iNove, however as far as i can tell ….

    $comments_by_type

    Is not holding the value it should do, and therefore $trackback is storing nothing…

    The function in the functions file only counts the comments, but it’s never actually called anywhere in the comments file…. yet it’s the only place i see $comments_by_type referenced…

    Quite simply the variable that is suppose to hold information on pings (trackbacks & pingbacks in terms of comment “type”) is not holding that data.. and the count is also off…

    I’m not sure where the issue lies specifically because i’m not familiar with those methods or seperating and displaying comments in such a manner, so the best advice i can give you is to seek some assistance from the theme author or any coder was has used this approach before and is aware of any such problems..

    I spent a good amount of time looking and fiddling with the code, but i think anything i suggest at this point would be pure guess work on my part..

    Admittedly, i’m stumped.. ??

    Been having a bit more of a read, and i’m convinced what you have should work, providing all the necessary pieces of code exist..

    See this article..
    https://sivel.net/2008/10/wp-27-comment-separation/

    Note the area regarding the modification made to single.php, check yours has this because this information applies to you and your theme.

    Thread Starter nickaster

    (@nickaster)

    Yes! That worked. It was the stuff missing on single.php that was missing. Once again, you rock.

    Cheers…

    No problem matey… ??

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Trackbacks Showing as Comments’ is closed to new replies.